本文整理汇总了C#中System.CodeDom.CodeIndexerExpression类的典型用法代码示例。如果您正苦于以下问题:C# CodeIndexerExpression类的具体用法?C# CodeIndexerExpression怎么用?C# CodeIndexerExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeIndexerExpression类属于System.CodeDom命名空间,在下文中一共展示了CodeIndexerExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Constructor0_Deny_Unrestricted
public void Constructor0_Deny_Unrestricted ()
{
CodeIndexerExpression cie = new CodeIndexerExpression ();
Assert.AreEqual (0, cie.Indices.Count, "Indices");
Assert.IsNull (cie.TargetObject, "TargetObject");
cie.TargetObject = new CodeExpression ();
}
示例2: DeserializeAppConfigExpression
private static CodePropertyReferenceExpression DeserializeAppConfigExpression(string[] expressionParts)
{
int index = expressionParts.Length - 1;
CodePropertyReferenceExpression expression = new CodePropertyReferenceExpression {
PropertyName = expressionParts[index]
};
index--;
CodeIndexerExpression expression2 = new CodeIndexerExpression();
expression.TargetObject = expression2;
expression2.Indices.Add(new CodePrimitiveExpression(expressionParts[index]));
index--;
CodePropertyReferenceExpression expression3 = new CodePropertyReferenceExpression();
expression2.TargetObject = expression3;
expression3.PropertyName = expressionParts[index];
index--;
CodeTypeReferenceExpression expression4 = new CodeTypeReferenceExpression();
expression3.TargetObject = expression4;
expression4.Type.Options = (CodeTypeReferenceOptions) Enum.Parse(typeof(CodeTypeReferenceOptions), expressionParts[index]);
index--;
expression4.Type.BaseType = expressionParts[index];
index--;
while (index > 0)
{
expression4.Type.BaseType = expressionParts[index] + "." + expression4.Type.BaseType;
index--;
}
return expression;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:28,代码来源:PropertyReferenceSerializer.cs
示例3: Clone
public static CodeIndexerExpression Clone(this CodeIndexerExpression expression)
{
if (expression == null) return null;
CodeIndexerExpression e = new CodeIndexerExpression();
e.Indices.AddRange(expression.Indices.Clone());
e.TargetObject = expression.TargetObject.Clone();
e.UserData.AddRange(expression.UserData);
return e;
}
示例4: Constructor1_Deny_Unrestricted
public void Constructor1_Deny_Unrestricted ()
{
CodeExpression target = new CodeExpression ();
CodeExpression[] indices = new CodeExpression[1] { target };
CodeIndexerExpression cie = new CodeIndexerExpression (target, indices);
Assert.AreEqual (1, cie.Indices.Count, "Indices");
Assert.AreSame (target, cie.TargetObject, "TargetObject");
cie.TargetObject = new CodeExpression ();
}
示例5: TypescriptIndexerExpression
public TypescriptIndexerExpression(
IExpressionFactory expressionFactory,
CodeIndexerExpression codeExpression,
CodeGeneratorOptions options)
{
_codeExpression = codeExpression;
_options = options;
_expressionFactory = expressionFactory;
System.Diagnostics.Debug.WriteLine("TypescriptIndexerExpression Created");
}
示例6: GenerateConstructorStatements
internal static void GenerateConstructorStatements(CodeConstructor ctor, string url, string appSettingUrlKey, string appSettingBaseUrl, bool soap11)
{
bool flag = (url != null) && (url.Length > 0);
bool flag2 = (appSettingUrlKey != null) && (appSettingUrlKey.Length > 0);
CodeAssignStatement statement = null;
if (flag || flag2)
{
CodeExpression expression;
CodePropertyReferenceExpression left = new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "Url");
if (flag)
{
expression = new CodePrimitiveExpression(url);
statement = new CodeAssignStatement(left, expression);
}
if (flag && !flag2)
{
ctor.Statements.Add(statement);
}
else if (flag2)
{
CodeVariableReferenceExpression expression3 = new CodeVariableReferenceExpression("urlSetting");
CodeTypeReferenceExpression targetObject = new CodeTypeReferenceExpression(typeof(ConfigurationManager));
CodePropertyReferenceExpression expression5 = new CodePropertyReferenceExpression(targetObject, "AppSettings");
expression = new CodeIndexerExpression(expression5, new CodeExpression[] { new CodePrimitiveExpression(appSettingUrlKey) });
ctor.Statements.Add(new CodeVariableDeclarationStatement(typeof(string), "urlSetting", expression));
if ((appSettingBaseUrl == null) || (appSettingBaseUrl.Length == 0))
{
expression = expression3;
}
else
{
if ((url == null) || (url.Length == 0))
{
throw new ArgumentException(Res.GetString("IfAppSettingBaseUrlArgumentIsSpecifiedThen0"));
}
string str = new Uri(appSettingBaseUrl).MakeRelative(new Uri(url));
CodeExpression[] parameters = new CodeExpression[] { expression3, new CodePrimitiveExpression(str) };
expression = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(string)), "Concat", parameters);
}
CodeStatement[] trueStatements = new CodeStatement[] { new CodeAssignStatement(left, expression) };
CodeBinaryOperatorExpression condition = new CodeBinaryOperatorExpression(expression3, CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression(null));
if (flag)
{
ctor.Statements.Add(new CodeConditionStatement(condition, trueStatements, new CodeStatement[] { statement }));
}
else
{
ctor.Statements.Add(new CodeConditionStatement(condition, trueStatements));
}
}
}
}
示例7: Emit
// Generates a codedom indexed identifier: one that is an identifier followed by an indexer: ex foo[1].
public static CodeExpression Emit(IndexedIdentifier indexedIdentifier)
{
// Create the codedom indexer expression
var codeIndex = new CodeIndexerExpression();
// Set the object that is being indexed.
codeIndex.TargetObject = new CodeVariableReferenceExpression(indexedIdentifier.Name);
// Set the expression that is generating the index.
codeIndex.Indices.Add(CodeDomEmitter.EmitCodeExpression(indexedIdentifier.ChildExpressions[0]));
return codeIndex;
}
示例8: SetScenarioSetup
public virtual void SetScenarioSetup(CodeMemberMethod memberMethod)
{
//ScenarioContext
var scenarioContext = new CodeTypeReferenceExpression("ScenarioContext");
// .Current
var currentContext = new CodePropertyReferenceExpression(scenarioContext, "Current");
// ["SomeKey"]
var indexer = new CodeIndexerExpression(currentContext, new CodePrimitiveExpression(CALLING_FEATURE_KEY));
// = this;
var assignMent = new CodeAssignStatement(indexer, new CodeThisReferenceExpression());
//ScenarioContext.Current["SomeKey"] = this;
memberMethod.Statements.Add(assignMent);
}
示例9: ToClass
public CodeTypeDeclaration ToClass()
{
var cs = new CodeTypeDeclaration(this.Name);
var iname = "I" + cs.Name;
if (cs.Name.Contains('`'))
{
cs.Name = cs.Name.Substring(0, cs.Name.Length - 2);
if (cs.Name.EndsWith("Base"))
{
iname = "I" + cs.Name.Substring(0, cs.Name.Length - 4);
}
cs.Name += "<T>";
}
if (iname != null)
{
cs.BaseTypes.Add(new CodeTypeReference(iname));
}
cs.IsPartial = true;
foreach (var p in Properties)
{
if (p.IsInherited) continue;
var prop = new CodeMemberProperty();
prop.Attributes = MemberAttributes.Public | MemberAttributes.Final;
prop.Name = p.Name;
prop.Type = new CodeTypeReference(p.Type);
prop.HasGet = true;
prop.HasSet = false;
var indexer = new CodeIndexerExpression(new CodeThisReferenceExpression(), new CodePrimitiveExpression(p.Name));
var cast = new CodeCastExpression(prop.Type, indexer);
prop.GetStatements.Add(new CodeMethodReturnStatement(cast));
cs.Members.Add(prop);
}
return cs;
}
示例10: BuildControlSkinAssignmentStatement
private CodeStatement BuildControlSkinAssignmentStatement(ControlBuilder builder, string skinID)
{
Type controlType = builder.ControlType;
string name = base.GetMethodNameForBuilder(BaseTemplateCodeDomTreeGenerator.buildMethodPrefix, builder) + "_skinKey";
CodeMemberField field = new CodeMemberField(typeof(object), name) {
Attributes = MemberAttributes.Private | MemberAttributes.Static
};
CodeMethodInvokeExpression expression = new CodeMethodInvokeExpression {
Method = new CodeMethodReferenceExpression(new CodeTypeReferenceExpression(typeof(PageTheme)), "CreateSkinKey")
};
expression.Parameters.Add(new CodeTypeOfExpression(controlType));
expression.Parameters.Add(new CodePrimitiveExpression(skinID));
field.InitExpression = expression;
base._sourceDataClass.Members.Add(field);
CodeFieldReferenceExpression targetObject = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "__controlSkins");
CodeIndexerExpression left = new CodeIndexerExpression(targetObject, new CodeExpression[] { new CodeVariableReferenceExpression(name) });
CodeDelegateCreateExpression expression4 = new CodeDelegateCreateExpression(this._controlSkinDelegateType, new CodeThisReferenceExpression(), base.GetMethodNameForBuilder(BaseTemplateCodeDomTreeGenerator.buildMethodPrefix, builder));
CodeObjectCreateExpression right = new CodeObjectCreateExpression(this._controlSkinType, new CodeExpression[0]);
right.Parameters.Add(new CodeTypeOfExpression(controlType));
right.Parameters.Add(expression4);
return new CodeAssignStatement(left, right);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:22,代码来源:PageThemeCodeDomTreeGenerator.cs
示例11: Emit
public void Emit (CodeTypeDeclaration ctd, CodeMemberMethod copy, CodeExpression copyarray,
CodeMemberMethod clone, CodeExpression other)
{
// The field itself
CodeMemberField f = new CodeMemberField ();
f.Name = Name;
f.Attributes = MemberAttributes.Public;
f.LinePragma = Line;
f.Type = Type.AsCodeDom;
f.CustomAttributes.Add (FieldAttr);
ctd.Members.Add (f);
// Copy statement in CopyItems
CodeIndexerExpression index = new CodeIndexerExpression ();
index.TargetObject = copyarray;
index.Indices.Add (ResultBuilder.BasePlusN (Idx));
CodeFieldReferenceExpression fld = CDH.ThisDot (Name);
CodeMethodInvokeExpression conv =
new CodeMethodInvokeExpression (CDH.This, "FieldAsResult",
new CodeExpression[] { fld });
CodeAssignStatement assg =
new CodeAssignStatement (index, conv);
copy.Statements.Add (assg);
// Add statement to clone result in CloneItems
CodeFieldReferenceExpression lhs =
new CodeFieldReferenceExpression (other, Name);
conv = new CodeMethodInvokeExpression (CDH.This, "CloneField",
new CodeExpression[] { fld });
assg = new CodeAssignStatement (lhs, new CodeCastExpression (f.Type, conv));
clone.Statements.Add (assg);
}
示例12: Correct
private void Correct(ref CodeObject target, CodeObject parent, int indent)
{
if (target is CodeVariableReferenceExpression)
{
CodeVariableReferenceExpression variableExpr = (CodeVariableReferenceExpression) target;
if (StringUtils.CaseInsensitiveEquals(variableExpr.VariableName, _setValueName))
{
variableExpr.VariableName = _propertyName;
}
}
else if (target is CodeMethodInvokeExpression)
{
CodeMethodInvokeExpression methodInvokeExpr = (CodeMethodInvokeExpression) target;
if (methodInvokeExpr.Method.TargetObject == null && StringUtils.CaseInsensitiveEquals(methodInvokeExpr.Method.MethodName, _setValueName))
{
CodeIndexerExpression indexerExpr = new CodeIndexerExpression(
new CodeVariableReferenceExpression(_propertyName));
indexerExpr.Indices.AddRange(methodInvokeExpr.Parameters);
target = indexerExpr;
}
}
}
示例13: GenerateSetAdaptersCode
internal void GenerateSetAdaptersCode(BrowserDefinition bd, CodeMemberMethod cmm)
{
foreach (DictionaryEntry entry in bd.Adapters)
{
string key = (string) entry.Key;
string str2 = (string) entry.Value;
CodePropertyReferenceExpression targetObject = new CodePropertyReferenceExpression(this._browserCapsRefExpr, "Adapters");
CodeIndexerExpression expression2 = new CodeIndexerExpression(targetObject, new CodeExpression[] { new CodePrimitiveExpression(key) });
CodeAssignStatement statement = new CodeAssignStatement {
Left = expression2,
Right = new CodePrimitiveExpression(str2)
};
cmm.Statements.Add(statement);
}
if (bd.HtmlTextWriterString != null)
{
CodeAssignStatement statement2 = new CodeAssignStatement {
Left = new CodePropertyReferenceExpression(this._browserCapsRefExpr, "HtmlTextWriter"),
Right = new CodePrimitiveExpression(bd.HtmlTextWriterString)
};
cmm.Statements.Add(statement2);
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:23,代码来源:BrowserCapabilitiesCodeGenerator.cs
示例14: GenerateIndexerExpression
protected override void GenerateIndexerExpression(CodeIndexerExpression e)
{
base.GenerateExpression(e.TargetObject);
if (e.TargetObject is CodeBaseReferenceExpression)
{
base.Output.Write(".Item");
}
base.Output.Write("(");
bool flag = true;
foreach (CodeExpression expression in e.Indices)
{
if (flag)
{
flag = false;
}
else
{
base.Output.Write(", ");
}
base.GenerateExpression(expression);
}
base.Output.Write(")");
}
示例15: GenerateIndexerExpression
protected override void GenerateIndexerExpression (CodeIndexerExpression e)
{
}