Extend the functionality of existing classes without damaging the consumer code

Here are a number of classes that are used to create from where Clause for SQL Server and Oracle for different field types, eg. text. numeric and date,

public interface IConditionBuilder
{
bool CanHandle (FilterAction filterAction);

string BuildCondition (SearchCondition filterCondition);
}

public abstract class ConditionBuilder : IConditionBuilder where TContext: FieldSearchContext
{
public abstract string OperatorSymbol {get; }

public string BuildCondition (SearchCondition searchCondition)
{
var conditionBuilder = new StringBuilder ();

var context = searchCondition.GetContext();

conditionBuilder.Append (context.FieldId);
conditionBuilder.Append (OperatorSymbol);
conditionBuilder.Append (GetValue (context));

return conditionBuilder.ToString ();
}

public abstract bool CanHandle (FilterAction filterAction);

public abstract object GetValue (TContext context);

}

public class TextLikeConditionBuilder: ConditionBuilder
{
public override string OperatorSymbol => "LIKE";

public override bool CanHandle (FilterAction action) => action == FilterAction.TextLike;

public override object GetValue (TextContext context)
{
if (context.Text == null)
{
return zero;
}

return string.Concat ("%", context.Text, "%");
}
}

public class TextEqualsConditionBuilder: ConditionBuilder
{
public override string OperatorSymbol => "=";

public override bool CanHandle (FilterAction action) => action == FilterAction.TextEqual;

public override object GetValue (TextContext context)
{
if (context.Text == null)
{
return zero;
}

return "& # 39;" + context.Text + "& # 39;";
}
}

public class NumericLessThanConditionBuilder: ConditionBuilder
{
public override string OperatorSymbol => " < ";

    public override bool CanHandle(FilterAction action) => action == FilterAction.NumericLessThan;

public override object GetValue (NumericContext Context)
{
return context.Number;
}
}

Public class DateGreaterThanAndLessThanEqualConditionBuilder: IConditionBuilder
{
public const string GREATER_THAN = ">";

public const string LESS_THAN_EQUAL = "<=";

public string BuildCondition (SearchCondition filterCondition)
{
var conditionBuilder = new StringBuilder ();

var context = filterCondition.GetContext();

conditionBuilder.Append (context.FieldId);
conditionBuilder.Append (GREATER_THAN);
conditionBuilder.Append ("& # 39;" + context.FromDate + "& # 39;");
conditionBuilder.Append (LESS_THAN_EQUAL);
conditionBuilder.Append ("& # 39;" + context.EndDate + "& # 39;");
return conditionBuilder.ToString ();
}

public bool CanHandle (FilterAction action) => action == FilterAction.DateGreaterThanLessThan;

}

I would like to extend the functionality to purge context.FieldId before creating it condition Statement for e.g. These classes create a statement like Name = & # 39; Aashish & # 39;I want the classes to create statement as [Name] = & # 39; Aashish & # 39;, These classes are used by other developers, so I do not want to restrict consumer functionality because of the changes I'm about to make. Basically, the open-closed principle applies. So, here's how I implemented these changes. Notice how I added a virtual feature SanitizeFieldId in the Condition Builder and DateGreaterThanAndLessThanEqualConditionBuilder,

public abstract class ConditionBuilder : IConditionBuilder where TContext: FieldSearchContext
{
public abstract string OperatorSymbol {get; }

public string BuildCondition (SearchCondition searchCondition)
{
var conditionBuilder = new StringBuilder ();

var context = searchCondition.GetContext();

conditionBuilder.Append (SanitizeFieldId (context.FieldId));
conditionBuilder.Append (OperatorSymbol);
conditionBuilder.Append (GetValue (context));

return conditionBuilder.ToString ();
}

public abstract bool CanHandle (FilterAction filterAction);

public abstract object GetValue (TContext context);

protected virtual string SanitizeFieldId (string fieldId)
{
return fieldId;
}
}

Public class DateGreaterThanAndLessThanEqualConditionBuilder: IConditionBuilder
{
public const string GREATER_THAN = ">";

public const string LESS_THAN_EQUAL = "<=";

public string BuildCondition (SearchCondition filterCondition)
{
var conditionBuilder = new StringBuilder ();

var context = filterCondition.GetContext();

conditionBuilder.Append (SanitizeFieldId (context.FieldId));
conditionBuilder.Append (GREATER_THAN);
conditionBuilder.Append ("& # 39;" + context.FromDate + "& # 39;");
conditionBuilder.Append (LESS_THAN_EQUAL);
conditionBuilder.Append ("& # 39;" + context.EndDate + "& # 39;");
return conditionBuilder.ToString ();
}

public bool CanHandle (FilterAction action) => action == FilterAction.DateGreaterThanLessThan;

protected virtual string SanitizeFieldId (string fieldId)
{
return fieldId;
}
}

public class SanitizedFieldConditionBuiler : ConditionBuilder Where: TContext: FieldSearchContext
{
private ConditionBuilder _baseConditionBuilder;
private IColumnSanitizer _columnSanitizer;

public SanitizedFieldConditionBuiler (ConditionBuilder baseConditionBuilder, IColumnSanitizer columnSanitizer)
{
_baseConditionBuilder = baseConditionBuilder;
_columnSanitizer = columnSanitizer;
}

public override string OperatorSymbol => _baseConditionBuilder.OperatorSymbol;

public override bool CanHandle (FilterAction filterAction) => _baseConditionBuilder.CanHandle (filterAction);

public override object GetValue (TContext context) => _baseConditionBuilder.GetValue (context);

protected override string SanitizeFieldId (string fieldId)
{
return _columnSanitizer.Sanitize (fieldId);
}
}

public class SanitizedDateFieldGreaterThanAndLessThanEqualConditionBuilder: DateGreaterThanAndLessThanEqualConditionBuilder
{
private IColumnSanitizer _columnSanitizer;

public SanitizedDateFieldGreaterThanAndLessThanEqualConditionBuilder (IColumnSanitizer columnSanitizer)
{
_columnSanitizer = columnSanitizer;
}

protected override string SanitizeFieldId (string fieldId)
{
return _columnSanitizer.Sanitize (fieldId);
}
}

I use extension methods to initialize SanitizedFieldConditionBuilerand SanitizedDateFieldGreaterThanAndLessThanEqualConditionBuilderAs shown below:

public static class extensions
{
public static SanitizedFieldConditionBuiler SanitizeField(This ConditionBuilder source, IColumnSanitizer columnSanitizer) where TContext: FieldSearchContext
{
Return the new SanitizedFieldConditionBuiler(Source, columnSanitizer);
}

public static SanitizedDateFieldGreaterThanAndLessThanEqualConditionBuilder SanitizeField (this IConditionBuilder source, IColumnSanitizer columnSanitizer)
{
return new SanitizedDateFieldGreaterThanAndLessThanEqualConditionBuilder (columnSanitizer);
}

}

Disinfection is available via an interface IColumnSanitizer and has two different implementations, for SQL Server and Oracle

    public interface IColumnSanitizer
{
string sanitize (string columnName);
}

public class SqlSanitizer: IColumnSanitizer
{
public string sanitize (string columnName)
{
Return "[" + columnName + "]";
}
}

public class OracleSanitizer: IColumnSanitizer
{
public string sanitize (string columnName)
{
return "" "+ columnName +"  "";
}
}

The following describes how to implement context classes:

public abstract class FieldSearchContext
{
public virtual string FieldId {get; }

protected FieldSearchContext (string fieldId)
{
FieldId = fieldId;
}
}

public class DateContext: FieldSearchContext
{
public DateContext (string fieldId, DateTime? fromDate, DateTime? endDate): base (fieldId)
{
FromDate = fromDate;
EndDate = endDate;
}

public DateTime? FromDate {get; }

public DateTime? EndDate {get; }
}

public class TextContext: FieldSearchContext
{
public TextContext (string fieldId, string text): base (fieldId)
{
Text = text;
}

public string text {get; }
}

public class NumericContext: FieldSearchContext
{
public NumericContext (string fieldId, decimal): base (fieldId)
{
Number = number;
}

public decimal {get; }
}

These changes work fine, but I want to find out if this can be achieved in a different and better way.

Use the following code to see it in action:

    Class program
{
static gap Main (string[] arguments)
{
var conditions = new List()
{
new SearchCondition (new NumericContext ("Numeric Field", 1234), FilterAction.NumericLessThan),
new search condition (new TextContext ("Text Field", "ASDF"), FilterAction.TextEqual),
new search condition (new TextContext ("Text Field", "QWERTY"), FilterAction.TextLike),
new search condition (new DateContext ("Date Field", DateTime.Now, DateTime.Now.AddYears (1)), FilterAction.DateGreaterThanLessThan)
};

Console.WriteLine (BuildWhereClause (Operation.AND, Conditions));
Console.Read ();
}

private static string BuildWhereClause (Operation operation, IList Conditions)
{
var returnValue = new list();
var conditionBuilders = new list()
{
new TextEqualsConditionBuilder (). SanitizeField (new SqlSanitizer ()),
new NumericLessThanConditionBuilder (). SanitizeField (new SqlSanitizer ()),
new TextLikeConditionBuilder (). SanitizeField (new SqlSanitizer ()),
new DateGreaterThanAndLessThanEqualConditionBuilder (). SanitizeField (new SqlSanitizer ())
};

foreach (var condition in conditions)
{
var context = condition.GetContext();
var conditionBuilder = conditionBuilders.FirstOrDefault (u => u.CanHandle (condition.FilterAction));
returnValue.Add (conditionBuilder.BuildCondition (condition));
}

if (returnValue.Any ())
return string.Join (Convert.ToString ("" + operation + ""), returnValue);

return string.Empty;
}
}

enum operation: int
{
AND = 1,
OR = 2
}

azure – How do I extend my Log Analytics AzureDiagnostics log data?

A solution we provided to Azure collects tons of data. We have enabled diagnostic logging for each resource and have everything go to a Log Analytics workspace. What we do not understand is why the log entries seem to contain no data:

Here's the query I made to show how much data we've collected in the last 7 days:

Azure Diagnostics
| group count () by ResourceProvider, Category
| Sort by ResourceProvider in ascending order
, Category ascending

This gives the following results:

Summary of the diagnostic data

When I run the following query:

Azure Diagnostics
| where ResourceProvider == "MICROSOFT.NETWORK" and Category == "ApplicationGatewayPerformanceLog"

I get tons of results that look like this:

Azure Diagnostics query results

Why are there no additional data in these log entries?

Magento 2. How can I properly extend vendor / composer / installed.json?

  • I suppose that installierte.json contains all dependencies for Magento,
  • How can I extend properly Manufacturer / Composer / Installed.json?

Context:

  • Magento has one heavy Dependence on one of the libraries, more specifically, a particular third-party version Module MSP / Recaptcha: 2.0.2, I want to update it to 2.1.2.
  • If it were a softer dependency (~ 2.0.2), I could have done this from composer.json, as described in the answer to that question

At this point, it should be clear what I have to accomplish and why. Please ask for more details if needed. Many Thanks.

Extend IdentityUser with nullable foreign key to another IdentityUser

I'm working on a framework based on .NET Core Identity. Let's say I wanted to extend that Identity User class with a ParentUserId Property, while the developer should still be able to decide which type for the TKey Primary key. This property would be a foreign key to another user, but it could be zero if the user has no parent.

Use string to the TKey would work without problems, as strings are nullable and do not conflict with that TKey is IEquatable Compulsion (though I do not know why). But if the developer decides to use intI'm shitty.

Currently, I think about a solution like this:

public class FrameworkUser : IdentityUser 
       TKey is IEquatable
{
public virtual TNullableKey ParentUserId {get; to adjust; }

// Navigation property dependent on ParentUserId
public virtual frameworkuser ParentUser {get; to adjust; }
}

But I am very insecure and do not like it.

  1. The developer could do something like that new FrameworkUser() accidentally (could be intercepted at runtime). Would be great if something would please Where TNullableKey is Nullable were possible.

  2. I can not restrict TNullableKey, IEquatable does not allow nullable value types (i.e. int?), although I do not know if this will lead to worse performance anyway if used as a foreign key. struct does not allow strings.

  3. The value of ParentUserId differs depending on the type. For example, to surely get the value of one int?I would look int? .HasValue his true and then it's worth it int? .Value, The same procedure is for a string that could be zero, empty or a few characters. This would make it difficult to switch from one type to another without extra work.

Another solution might have two implementations, one for string and one for structbut that does not work, because then I would have two Identity gatess and so on.

So, what would you do?

pathfinder – Wizard's Battleshaping: Extend Duration & Consider Magic?

Yes they are

Just as with the magic spells or magical weapon spells, targets are taken into account Magic Weapons because the source of these bonus bonuses is also a magical source, battleshaping, a supernatural ability.

As far as I know, there is not a single source of enhancement bonuses that is not a spell, spell, or supernatural ability, other than the master-grade bonus. For clarity, the magic weapons are defined as follows:

A magic weapon has been improved to get a real hit and do more damage. Magic weapons have upgrade bonuses from +1 to +5. They apply these bonuses to both attack and damage rolls when used in combat. All magical weapons are also master weapons, but their master bonuses on attack rolls do not stack with their upgrade bonuses on attack rolls.

For the extension of the term there are none. If it was a magical ability, you can use the "Extend Enchanting Ability" monster talent instead.

sharepoint online – Extend the Document Information Panel (DIP) with data from the API

The document information panel in the modern SharePoint Online Document Library view displays the properties configured in the site content type, as well as general sharing or change information from the document.

How is it possible to add a section to this panel without creating a new panel? like e. G. the article of ypcode here?

I want to use the SharePoint document ID to get more information from an external API and render that information in a list.

Can use animation to positively extend user experience

When users use an app or website, different efforts and cognitive burdens are required at each point of the user journey.

While various negative factors may cause UX to potentially shorten a user's journey, Would it be possible for different types of animation, such as micro-interactions and transitions, to have a positive impact on extending the user's journey?

This may be analogous to how certain games reward users with video clips, animations, or virtual rewards at the end of a task or goal.

Can delivering small doses of sexy animations at the end of each task / goal extend a user's journey?

e.g. Compare showing a registration confirmation animation at the end of a longer registration form and display only a static confirmation message. Would the version that had the animation have a positive impact on the rest of the users?

Have you previously carried out examinations, or do you have experiences or examples that could relate to them?