本文整理汇总了C#中this.Add方法的典型用法代码示例。如果您正苦于以下问题:C# this.Add方法的具体用法?C# this.Add怎么用?C# this.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类this
的用法示例。
在下文中一共展示了this.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MapLocalizedStorefrontRoute
/// <summary>
/// Generate extra three routing for specified url {store}/url, {store}/{language}/url, {language}/url, url
/// </summary>
/// <param name="routes"></param>
/// <param name="name"></param>
/// <param name="url"></param>
/// <param name="defaults"></param>
/// <param name="constraints"></param>
/// <param name="routeFactory"></param>
public static void MapLocalizedStorefrontRoute(this RouteCollection routes, string name, string url, object defaults, object constraints, Func<string, Route> routeFactory)
{
var languageConstrain = @"[a-z]{2}-[A-Z]{2}";
var languageWithStoreRoute = routeFactory(@"{store}/{language}/" + url);
languageWithStoreRoute.Defaults = new RouteValueDictionary(defaults);
languageWithStoreRoute.Constraints = new RouteValueDictionary(constraints);
languageWithStoreRoute.DataTokens = new RouteValueDictionary();
languageWithStoreRoute.Constraints.Add("language", languageConstrain);
routes.Add(name + "StoreWithLang", languageWithStoreRoute);
var languageRoute = routeFactory(@"{language}/" + url);
languageRoute.Defaults = new RouteValueDictionary(defaults);
languageRoute.Constraints = new RouteValueDictionary(constraints);
languageRoute.DataTokens = new RouteValueDictionary();
languageRoute.Constraints.Add("language", languageConstrain);
routes.Add(name + "Lang", languageRoute);
var storeRoute = routeFactory(@"{store}/" + url);
storeRoute.Defaults = new RouteValueDictionary(defaults);
storeRoute.Constraints = new RouteValueDictionary(constraints);
storeRoute.DataTokens = new RouteValueDictionary();
routes.Add(name + "Store", storeRoute);
var route = routeFactory(url);
route.Defaults = new RouteValueDictionary(defaults);
route.Constraints = new RouteValueDictionary(constraints);
route.DataTokens = new RouteValueDictionary();
routes.Add(name, route);
}
示例2: AddLabeledSlider
public static void AddLabeledSlider(this Menu menu, string name, string displayName, string[] values,
int defaultValue = 0)
{
var slider = menu.Add(name, new Slider(displayName, defaultValue, 0, values.Length - 1));
var text = menu.Add(name + "label", new Label(values[slider.CurrentValue]));
slider.OnValueChange += delegate { text.DisplayName = values[slider.CurrentValue]; };
}
示例3: JumblistMapRoute
public static void JumblistMapRoute( this RouteCollection routes, string name, string url, object defaults, string[] namespaces, object constraints )
{
if ( routes == null )
throw new ArgumentNullException( "routes" );
if ( url == null )
throw new ArgumentNullException( "url" );
var route = new JumblistRoute( url, new MvcRouteHandler() )
{
Defaults = new RouteValueDictionary( defaults ),
Constraints = new RouteValueDictionary( constraints ),
DataTokens = new RouteValueDictionary()
};
if ( (namespaces != null) && (namespaces.Length > 0) )
{
route.DataTokens["Namespaces"] = namespaces;
}
if ( String.IsNullOrEmpty( name ) )
routes.Add( route );
else
routes.Add( name, route );
}
示例4: AddProperty
private static void AddProperty(this IDictionary<string, object> parms, PropertyInfo p, object o, string prefix = "")
{
object value = p.GetValue(o);
// filter out sentinals values for unitialized search fields
if (value != null && !value.Equals(0) && !value.Equals(DateTime.MinValue))
{
// if the property is a string just add it
if (value is string)
parms.Add(prefix + p.Name, value);
// value types
else if (value.GetType().GetTypeInfo().IsValueType)
{
// serialize dates in the correct format
if (value is DateTime)
parms.Add(prefix + p.Name, ((DateTime)value).ToString("yyyy-MM-dd"));
else
parms.Add(prefix + p.Name, value);
}
// the property is a list in which case search on the first item's value - committee_ids is an example
else if (value is IList<string> && ((IList<string>)value).Count > 0)
parms.Add(prefix + p.Name, ((IList<string>)value)[0]);
// the property is marked as searchable but is a sub ojbect - recurse adding
// this property name as a prefix (history.house_passage_result is an example)
else
parms.AddProperties(value, p.Name + ".");
}
}
示例5: Add
/// <summary>
/// Creates a direct or symbolic reference with the specified name and target
/// </summary>
/// <param name = "name">The name of the reference to create.</param>
/// <param name = "canonicalRefNameOrObjectish">The target which can be either the canonical name of a reference or a revparse spec.</param>
/// <param name = "allowOverwrite">True to allow silent overwriting a potentially existing reference, false otherwise.</param>
/// <param name = "refsColl">The <see cref="ReferenceCollection"/> being worked with.</param>
/// <param name="logMessage">The optional message to log in the <see cref="ReflogCollection"/> when adding the <see cref="Reference"/></param>
/// <returns>A new <see cref = "Reference" />.</returns>
public static Reference Add(this ReferenceCollection refsColl, string name, string canonicalRefNameOrObjectish, bool allowOverwrite = false, string logMessage = null)
{
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNullOrEmptyString(canonicalRefNameOrObjectish, "canonicalRefNameOrObjectish");
Reference reference;
RefState refState = TryResolveReference(out reference, refsColl, canonicalRefNameOrObjectish);
var gitObject = refsColl.repo.Lookup(canonicalRefNameOrObjectish, Core.GitObjectType.Any, LookUpOptions.None);
if (refState == RefState.Exists)
{
return refsColl.Add(name, reference, allowOverwrite, logMessage);
}
if (refState == RefState.DoesNotExistButLooksValid && gitObject == null)
{
using (ReferenceSafeHandle handle = Proxy.git_reference_symbolic_create(refsColl.repo.Handle, name, canonicalRefNameOrObjectish, allowOverwrite))
{
return Reference.BuildFromPtr<Reference>(handle, refsColl.repo);
}
}
Ensure.GitObjectIsNotNull(gitObject, canonicalRefNameOrObjectish);
return refsColl.Add(name, gitObject.Id, allowOverwrite, logMessage);
}
示例6: Compare
public static void Compare(this Collection<Client> Collection, IEnumerable<Client> Items)
{
if (Items.Count() > 0)
{
Collection<Client> Temporary = new Collection<Client>();
foreach (Client c in Collection)
{
Temporary.Add(c);
}
Collection.Clear(); // Remove our items
bool bHasItems = (Temporary.Count() > 0) ? true : false;
foreach (Client c in Items) // For each item in our enumeration
{
if (bHasItems) // If our current collection has any items
{
foreach (Client e in Temporary) // For each item in our temporary collection
{
if (c.Id == e.Id) // If the Id is the same as the id in our items collection
Collection.Add(c); // Add to the current collection
}
}
else // If we have no items in our collection
Collection.Add(c); // Add all the items to our collection
}
}
}
示例7: AddAspNetStart
public static CreateProject AddAspNetStart(this CreateProject project, bool full)
{
string appStartUpTemplate = Resources.AspNet.Startup
.Replace("[{namespace}]", $"{project.Parameter.ProjectName}");
appStartUpTemplate = appStartUpTemplate
.Replace("[{factoryUsing}]", !full ? string.Empty : $"using {project.Parameter.SolutionParam.SolutionName}.Business.Factory;")
.Replace("[{factoryInit}]", !full ? string.Empty : "Register.Do(appSettings.UnitTest);")
.Replace("[{name}]", GetSafeName(project.Parameter.SolutionParam.SolutionName));
string appProgramTemplate = Resources.AspNet.Program
.Replace("[{namespace}]", $"{project.Parameter.ProjectName}");
string appControllerTemplate = Resources.AspNet.HomeController
.Replace("[{namespace}]", $"{project.Parameter.ProjectName}.Controllers");
CreateFile appStartUp = new CreateFile(new CreateFileParam(project.Parameter, "Code", "Startup.cs") { Template = appStartUpTemplate });
project.Add(appStartUp);
CreateFile appProgram = new CreateFile(new CreateFileParam(project.Parameter, "Code", "Program.cs") { Template = appProgramTemplate });
project.Add(appProgram);
CreateFile appController = new CreateFile(new CreateFileParam(project.Parameter, "Controllers", "HomeController.cs") { Template = appControllerTemplate });
project.Add(appController);
return project;
}
示例8: Add
/// <summary>
/// Creates a direct or symbolic reference with the specified name and target
/// </summary>
/// <param name="refsColl">The <see cref="ReferenceCollection"/> being worked with.</param>
/// <param name="name">The name of the reference to create.</param>
/// <param name="canonicalRefNameOrObjectish">The target which can be either the canonical name of a reference or a revparse spec.</param>
/// <param name="signature">The identity used for updating the reflog</param>
/// <param name="logMessage">The optional message to log in the <see cref="ReflogCollection"/> when adding the <see cref="Reference"/></param>
/// <param name="allowOverwrite">True to allow silent overwriting a potentially existing reference, false otherwise.</param>
/// <returns>A new <see cref="Reference"/>.</returns>
public static Reference Add(this ReferenceCollection refsColl, string name, string canonicalRefNameOrObjectish, Signature signature, string logMessage, bool allowOverwrite = false)
{
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNullOrEmptyString(canonicalRefNameOrObjectish, "canonicalRefNameOrObjectish");
Reference reference;
RefState refState = TryResolveReference(out reference, refsColl, canonicalRefNameOrObjectish);
var gitObject = refsColl.repo.Lookup(canonicalRefNameOrObjectish, GitObjectType.Any, LookUpOptions.None);
if (refState == RefState.Exists)
{
return refsColl.Add(name, reference, signature, logMessage, allowOverwrite);
}
if (refState == RefState.DoesNotExistButLooksValid && gitObject == null)
{
using (ReferenceSafeHandle handle = Proxy.git_reference_symbolic_create(refsColl.repo.Handle, name, canonicalRefNameOrObjectish, allowOverwrite,
signature.OrDefault(refsColl.repo.Config), logMessage))
{
return Reference.BuildFromPtr<Reference>(handle, refsColl.repo);
}
}
Ensure.GitObjectIsNotNull(gitObject, canonicalRefNameOrObjectish);
if (logMessage == null)
{
logMessage = string.Format("{0}: Created from {1}",
name.LooksLikeLocalBranch() ? "branch" : "reference", canonicalRefNameOrObjectish);
}
refsColl.EnsureHasLog(name);
return refsColl.Add(name, gitObject.Id, signature, logMessage, allowOverwrite);
}
示例9: AddChiLocalization
public static IServiceCollection AddChiLocalization(this IServiceCollection services, string path)
{
services.Add(new ServiceDescriptor(
typeof(IGettextProcessor),
sp => new DefaultGettextProcessor(path),
ServiceLifetime.Singleton
));
services.Add(new ServiceDescriptor(
typeof(IStringLocalizerFactory),
typeof(GettextStringLocalizerFactory),
ServiceLifetime.Singleton
));
services.Add(new ServiceDescriptor(
typeof(IStringLocalizer),
typeof(GettextStringLocalizer),
ServiceLifetime.Transient
));
services.Add(new ServiceDescriptor(
typeof(IStringLocalizer<>),
typeof(StringLocalizer<>),
ServiceLifetime.Transient
));
return services;
}
示例10: addSkillSheit
private static void addSkillSheit(this Menu m, string slot, int dh = 70,
int minh = 1, int maxh = 100, int dm = 30, int minm = 1, int maxm = 100)
{
m.Add(slot+".Enabled", new CheckBox("Use " + slot));
m.Add(slot + ".Hitchance", new Slider("Min Hitchance {0}%", dh, minh, maxh));
m.Add(slot + ".Mana", new Slider("Min Mana to use {0}%", dm, minm, maxm));
}
示例11: AddTarget
/// <summary>
/// Add the -target option to the given tool arguments builder.
/// </summary>
internal static void AddTarget(this List<string> builder)
{
#if BB
builder.Add(ToolOptions.Target.AsArg());
builder.Add("BlackBerry");
#endif
}
示例12: CompleteResolution
public static void CompleteResolution(this KAOSView view)
{
foreach (var resolution in view.Resolutions().ToArray()) {
view.Add (view.ParentModel.Elements.Single (x => x.Identifier == resolution.ResolvingGoalIdentifier));
view.Add (view.ParentModel.Elements.Single (x => x.Identifier == resolution.ObstacleIdentifier));
}
}
示例13: If
public static void If(this Collection<Instruction> ins,
Action<Collection<Instruction>> condition,
Action<Collection<Instruction>> thenStatement,
Action<Collection<Instruction>> elseStatement)
{
var ifEnd = Instruction.Create(OpCodes.Nop);
var ifElse = Instruction.Create(OpCodes.Nop);
condition(ins);
if (ins[ins.Count - 1].OpCode == OpCodes.Ceq)
{
ins[ins.Count - 1] = Instruction.Create(OpCodes.Bne_Un, ifElse);
}
else
{
ins.Add(Instruction.Create(OpCodes.Brfalse, ifElse));
}
thenStatement(ins);
ins.Add(Instruction.Create(OpCodes.Br, ifEnd));
ins.Add(ifElse);
elseStatement(ins);
ins.Add(ifEnd);
}
示例14: Apply
public static void Apply(this CssStyleCollection style, PrintSetting setting)
{
if (setting == null) return;
if (string.IsNullOrEmpty(setting.Top))
{ style.Remove("top"); }
else
{ style.Add("top", setting.Top); }
if (string.IsNullOrEmpty(setting.Left))
{ style.Remove("left"); }
else
{ style.Add("left", setting.Left); }
if (string.IsNullOrEmpty(setting.Font))
{ style.Remove("font"); }
else
{ style.Add("font", setting.Font); }
if (string.IsNullOrEmpty(setting.Size))
{ style.Remove("font-size"); }
else
{ style.Add("font-size", setting.Size); }
if (string.IsNullOrEmpty(setting.Width))
{ style.Remove("width"); }
else
{ style.Add("width", setting.Width); }
if (string.IsNullOrEmpty(setting.Height))
{ style.Remove("height"); }
else
{ style.Add("height", setting.Height); }
}
示例15: Add
public static void Add(this ImmutableArray<NavInfoNode>.Builder builder, string name, _LIB_LISTTYPE type, bool expandDottedNames)
{
if (name == null)
{
return;
}
if (expandDottedNames)
{
const char separator = '.';
var start = 0;
var separatorPos = name.IndexOf(separator, start);
while (separatorPos >= 0)
{
builder.Add(name.Substring(start, separatorPos - start), type);
start = separatorPos + 1;
separatorPos = name.IndexOf(separator, start);
}
if (start < name.Length)
{
builder.Add(name.Substring(start), type);
}
}
else
{
builder.Add(name, type);
}
}