本文整理汇总了C#中System.CodeDom.CodeTypeReferenceExpression类的典型用法代码示例。如果您正苦于以下问题:C# CodeTypeReferenceExpression类的具体用法?C# CodeTypeReferenceExpression怎么用?C# CodeTypeReferenceExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeTypeReferenceExpression类属于System.CodeDom命名空间,在下文中一共展示了CodeTypeReferenceExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ImportClass
public override void ImportClass()
{
SoapAddressBinding binding = (base.ImportContext.Port == null) ? null : ((SoapAddressBinding) base.ImportContext.Port.Extensions.Find(typeof(SoapAddressBinding)));
if (base.ImportContext.Style == ServiceDescriptionImportStyle.Client)
{
base.ImportContext.CodeTypeDeclaration.BaseTypes.Add(typeof(SoapHttpClientProtocol).FullName);
CodeConstructor ctor = WebCodeGenerator.AddConstructor(base.ImportContext.CodeTypeDeclaration, new string[0], new string[0], null, CodeFlags.IsPublic);
ctor.Comments.Add(new CodeCommentStatement(Res.GetString("CodeRemarks"), true));
bool flag = true;
if (base.ImportContext is Soap12ProtocolImporter)
{
flag = false;
CodeTypeReferenceExpression targetObject = new CodeTypeReferenceExpression(typeof(SoapProtocolVersion));
CodeFieldReferenceExpression right = new CodeFieldReferenceExpression(targetObject, Enum.Format(typeof(SoapProtocolVersion), SoapProtocolVersion.Soap12, "G"));
CodePropertyReferenceExpression left = new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "SoapVersion");
CodeAssignStatement statement = new CodeAssignStatement(left, right);
ctor.Statements.Add(statement);
}
ServiceDescription serviceDescription = base.ImportContext.Binding.ServiceDescription;
string url = (binding != null) ? binding.Location : null;
string appSettingUrlKey = serviceDescription.AppSettingUrlKey;
string appSettingBaseUrl = serviceDescription.AppSettingBaseUrl;
ProtocolImporterUtil.GenerateConstructorStatements(ctor, url, appSettingUrlKey, appSettingBaseUrl, flag && !base.ImportContext.IsEncodedBinding);
}
else if (base.ImportContext.Style == ServiceDescriptionImportStyle.Server)
{
base.ImportContext.CodeTypeDeclaration.BaseTypes.Add(typeof(WebService).FullName);
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:29,代码来源:SoapHttpTransportImporter.cs
示例2: ImportClass
public override void ImportClass() {
// grab this here so it gets marked "handled" for both client and server
SoapAddressBinding soapAddress = ImportContext.Port == null ? null : (SoapAddressBinding)ImportContext.Port.Extensions.Find(typeof(SoapAddressBinding));
if (ImportContext.Style == ServiceDescriptionImportStyle.Client) {
ImportContext.CodeTypeDeclaration.BaseTypes.Add(typeof(SoapHttpClientProtocol).FullName);
CodeConstructor ctor = WebCodeGenerator.AddConstructor(ImportContext.CodeTypeDeclaration, new string[0], new string[0], null, CodeFlags.IsPublic);
ctor.Comments.Add(new CodeCommentStatement(Res.GetString(Res.CodeRemarks), true));
bool soap11 = true;
if (ImportContext is Soap12ProtocolImporter) {
soap11 = false;
// add version code
CodeTypeReferenceExpression versionEnumTypeReference = new CodeTypeReferenceExpression(typeof(SoapProtocolVersion));
CodeFieldReferenceExpression versionEnumFieldReference = new CodeFieldReferenceExpression(versionEnumTypeReference, Enum.Format(typeof(SoapProtocolVersion), SoapProtocolVersion.Soap12, "G"));
CodePropertyReferenceExpression versionPropertyReference = new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "SoapVersion");
CodeAssignStatement assignVersionStatement = new CodeAssignStatement(versionPropertyReference, versionEnumFieldReference);
ctor.Statements.Add(assignVersionStatement);
}
ServiceDescription serviceDescription = ImportContext.Binding.ServiceDescription;
string url = (soapAddress != null) ? soapAddress.Location : null;
string urlKey = serviceDescription.AppSettingUrlKey;
string baseUrl = serviceDescription.AppSettingBaseUrl;
ProtocolImporterUtil.GenerateConstructorStatements(ctor, url, urlKey, baseUrl, soap11 && !ImportContext.IsEncodedBinding);
}
else if (ImportContext.Style == ServiceDescriptionImportStyle.Server) {
ImportContext.CodeTypeDeclaration.BaseTypes.Add(typeof(WebService).FullName);
}
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:27,代码来源:SoapHttpTransportImporter.cs
示例3: Constructor1_Deny_Unrestricted
public void Constructor1_Deny_Unrestricted ()
{
CodeTypeReference type = new CodeTypeReference ("System.Int32");
CodeTypeReferenceExpression ctre = new CodeTypeReferenceExpression (type);
Assert.AreSame (type, ctre.Type, "Type");
ctre.Type = new CodeTypeReference ("System.Void");
}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:CodeTypeReferenceExpressionCas.cs
示例4: CodeTypeOperationExpression
/// <summary>
/// Initializes a new instance of the CodeTypeOperationExpression class.
/// </summary>
/// <param name="source">The source expression.</param>
/// <param name="targetType">The target type reference expression.</param>
protected CodeTypeOperationExpression(CodeExpression source, CodeTypeReferenceExpression targetType)
{
ExceptionUtilities.CheckArgumentNotNull(source, "source");
ExceptionUtilities.CheckArgumentNotNull(targetType, "targetType");
this.Source = source;
this.TargetType = targetType;
}
开发者ID:AlineGuan,项目名称:odata.net,代码行数:12,代码来源:CodeTypeOperationExpression.cs
示例5: Is
public static CodeExpression Is(CodeVariableReferenceExpression var,
CodeTypeReferenceExpression type, CodeDomProvider provider)
{
return new CodeSnippetExpression(
"((" + ExpressionToString(var, provider) + ") is " +
ExpressionToString(type, provider) + ")");
}
开发者ID:smoothfriction,项目名称:SmoothReflections,代码行数:7,代码来源:IltoCSharpConverter.cs
示例6: 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
示例7: CreateService
protected override CodeMemberMethod CreateService(CodeTypeReference typerefWCFService, CodeTypeReference typerefService)
{
CodeTypeReferenceExpression typerefexprService = new CodeTypeReferenceExpression(typerefService);
CodeMethodReferenceExpression methodrefDbusServiceCreate = new CodeMethodReferenceExpression(typerefexprService, "Create");
CodeMemberMethod methodCreateService = new CodeMemberMethod();
methodCreateService.Name = CreateServiceName;
methodCreateService.ReturnType = typerefWCFService;
methodCreateService.Attributes = MemberAttributes.Static;
methodCreateService.Parameters.Add(new CodeParameterDeclarationExpression(CodeBuilderCommon.typerefWCFServiceParams, nameWCFServiceParamsArg));
CodeMethodReferenceExpression methodrefCreateDbusService = new CodeMethodReferenceExpression(CodeBuilderCommon.typerefexprLookupTargetFunctions, CodeBuilderCommon.CreateDbusService);
methodrefCreateDbusService.TypeArguments.Add(typerefService);
methodCreateService.Statements.Add(new CodeVariableDeclarationStatement(typerefService, dbusService, // * <dbus_service> dbusService =
new CodeMethodInvokeExpression(methodrefCreateDbusService // * Udbus.WCF.Dbus.Service.LookupTargetFunctions.CreateDbusService(
, argrefWCFServiceParams // * wcfserviceparams
, methodrefDbusServiceCreate // * , <dbus_service>.Create // createService1
, methodrefDbusServiceCreate // * , <dbus_service>.Create // createService2
, new CodePropertyReferenceExpression(typerefexprService, CodeBuilderCommon.DefaultConnectionParameters) // * <dbus_service>.DefaultConnectionParameters);
)
));
// * <wcfservice> wcfService = new <wcfservice>(dbusservice);
methodCreateService.Statements.Add(new CodeVariableDeclarationStatement(typerefWCFService, wcfService
, new CodeObjectCreateExpression(typerefWCFService, varrefDbusService)
));
// return wcfService;
methodCreateService.Statements.Add(new CodeMethodReturnStatement(varrefWcfService));
return methodCreateService;
}
开发者ID:jean-edouard,项目名称:win-tools,代码行数:31,代码来源:WCFPassthruHostBuilder.cs
示例8: GetCodeExpression
public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
{
if (!entry.Expression.Contains(","))
{
throw new ArgumentException("Must include two numbers separated by a comma.");
}
else
{
// get two numbers
string[] numbers = entry.Expression.Split(',');
if (numbers.Length != 2)
{
throw new ArgumentException("Only include two numbers");
}
else
{
int lowerLimit, upperLimit;
if (Int32.TryParse(numbers[0], out lowerLimit) && Int32.TryParse(numbers[1], out upperLimit))
{
CodeTypeReferenceExpression typeRef = new CodeTypeReferenceExpression(this.GetType());
CodeExpression[] methodParameters = new CodeExpression[2];
methodParameters[0] = new CodePrimitiveExpression(lowerLimit);
methodParameters[1] = new CodePrimitiveExpression(upperLimit);
return new CodeMethodInvokeExpression(typeRef, "GetRandomNumber", methodParameters);
}
else
{
throw new ArgumentException("Use valid Integers");
}
}
}
}
开发者ID:bq-wang,项目名称:aspnet,代码行数:33,代码来源:RandomNumberExpressionBuilder.cs
示例9: Init
void Init ()
{
unit = new CodeCompileUnit ();
mainNS = new CodeNamespace ("ASP");
unit.Namespaces.Add (mainNS);
mainClass = new CodeTypeDeclaration (parser.ClassName);
mainClass.TypeAttributes = TypeAttributes.Public;
mainNS.Types.Add (mainClass);
mainClass.BaseTypes.Add (new CodeTypeReference (parser.BaseType.FullName));
mainClassExpr = new CodeTypeReferenceExpression ("ASP." + parser.ClassName);
foreach (object o in parser.Imports) {
if (o is string)
mainNS.Imports.Add (new CodeNamespaceImport ((string) o));
}
if (parser.Assemblies != null) {
foreach (object o in parser.Assemblies) {
if (o is string)
unit.ReferencedAssemblies.Add ((string) o);
}
}
// Late-bound generators specifics (as for MonoBASIC/VB.NET)
unit.UserData["RequireVariableDeclaration"] = parser.ExplicitOn;
unit.UserData["AllowLateBound"] = !parser.StrictOn;
AddInterfaces ();
AddClassAttributes ();
CreateStaticFields ();
AddApplicationAndSessionObjects ();
AddScripts ();
CreateConstructor (null, null);
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:33,代码来源:BaseCompiler.cs
示例10: Clone
public static CodeTypeReferenceExpression Clone(this CodeTypeReferenceExpression expression)
{
if (expression == null) return null;
CodeTypeReferenceExpression e = new CodeTypeReferenceExpression();
e.Type = expression.Type.Clone();
e.UserData.AddRange(expression.UserData);
return e;
}
开发者ID:jw56578,项目名称:SpecFlowTest,代码行数:8,代码来源:CodeTypeReferenceExpressionExtensions.cs
示例11: GetCodeExpression
public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
{
string property = (string) parsedData;
CodePrimitiveExpression prim = new CodePrimitiveExpression(property);
CodeExpression[] args = new[] {prim};
CodeTypeReferenceExpression refType = new CodeTypeReferenceExpression(this.GetType());
return new CodeMethodInvokeExpression(refType, "GetProperty", args);
}
开发者ID:dreamer777,项目名称:My.Common,代码行数:9,代码来源:ConfigExpressionBuilder.cs
示例12: TypescriptTypeReferenceExpression
public TypescriptTypeReferenceExpression(
CodeTypeReferenceExpression codeExpression,
CodeGeneratorOptions options,
ITypescriptTypeMapper typescriptTypeMapper)
{
_codeExpression = codeExpression;
_options = options;
_typescriptTypeMapper = typescriptTypeMapper;
System.Diagnostics.Debug.WriteLine("TypescriptTypeReferenceExpression Created");
}
开发者ID:s2quake,项目名称:TypescriptCodeDom,代码行数:10,代码来源:TypescriptTypeReferenceExpression.cs
示例13: CreateEmptyConstructor
internal CodeConstructor CreateEmptyConstructor()
{
// Example: new TestService() : this(NullAuthenticator.Instance)
var constructor = new CodeConstructor();
constructor.Attributes = MemberAttributes.Public;
var nullAuthenticator = new CodeTypeReferenceExpression(typeof(NullAuthenticator));
constructor.ChainedConstructorArgs.Add(new CodeFieldReferenceExpression(nullAuthenticator, "Instance"));
return constructor;
}
开发者ID:jithuin,项目名称:infogeezer,代码行数:10,代码来源:EasyConstructServiceDecorator.cs
示例14: Constructor2
public void Constructor2 ()
{
string baseType = "mono";
CodeTypeReferenceExpression ctre = new CodeTypeReferenceExpression (baseType);
Assert.IsNotNull (ctre.Type, "#1");
Assert.AreEqual (baseType, ctre.Type.BaseType, "#2");
ctre = new CodeTypeReferenceExpression ((string) null);
Assert.IsNotNull (ctre.Type, "#3");
Assert.AreEqual (typeof (void).FullName, ctre.Type.BaseType, "#4");
}
开发者ID:nlhepler,项目名称:mono,代码行数:12,代码来源:CodeTypeReferenceExpressionTest.cs
示例15: GetCodeExpression
public override CodeExpression GetCodeExpression(System.Web.UI.BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
{
_log.Write(_id, SPTraceLogger.TraceSeverity.InformationEvent, "GetCodeExpression", "Info", "Called");
CodeTypeReferenceExpression thisType = new CodeTypeReferenceExpression(base.GetType());
CodePrimitiveExpression expression = new CodePrimitiveExpression(entry.Expression.Trim().ToString());
string evaluationMethod = "GetKeyValue";
return new CodeMethodInvokeExpression(thisType, evaluationMethod, new CodeExpression[] { expression });
}
开发者ID:powareverb,项目名称:SPExpressionBuilder,代码行数:12,代码来源:SPUrlExpressionBuilder.cs
示例16: Generate
/// <summary>
/// Generates code for value
/// </summary>
/// <param name="parentClass">The parent class.</param>
/// <param name="method">The method.</param>
/// <param name="value">The value.</param>
/// <param name="baseName">Name of the base.</param>
/// <param name="dictionary">The dictionary.</param>
/// <returns></returns>
public CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null)
{
CodeExpression valueExpression = null;
if (value != null)
{
FontWeight fontWeight = (FontWeight)value;
CodeTypeReferenceExpression typeReference = new CodeTypeReferenceExpression("FontStyle");
valueExpression = new CodeFieldReferenceExpression(typeReference, fontWeight.ToString());
}
return valueExpression;
}
开发者ID:fearfullymade,项目名称:UI_Generator,代码行数:21,代码来源:FontWeightGeneratorValue.cs
示例17: 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));
}
}
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:52,代码来源:ProtocolImporterUtil.cs
示例18: SetTestInitializeMethod
public override void SetTestInitializeMethod(TestClassGenerationContext generationContext)
{
base.SetTestInitializeMethod(generationContext);
// SenarioContext.Current.SetTestInstance(this);
var scenarioContext = new CodeTypeReferenceExpression("ScenarioContext");
var currentContext = new CodePropertyReferenceExpression(scenarioContext, "Current");
var scenarioContextExtensions = new CodeTypeReferenceExpression("ScenarioContextExtensions");
var setTestInstance = new CodeMethodInvokeExpression(scenarioContextExtensions, "SetTestInstance",
currentContext, new CodeThisReferenceExpression());
// Add it to ScenarioSetup
generationContext.ScenarioInitializeMethod.Statements.Add(new CodeExpressionStatement(setTestInstance));
}
开发者ID:rdhatt,项目名称:SpecFlow,代码行数:14,代码来源:MsTestSilverlightGeneratorProvider.cs
示例19: CodeGeneratorInternalClass
static CodeGeneratorInternalClass()
{
CodeTypeReferenceExpression flagsType = new CodeTypeReferenceExpression ("System.Reflection.BindingFlags");
bindingFlags = new CodeBinaryOperatorExpression (
new CodeFieldReferenceExpression (flagsType, "Public"),
CodeBinaryOperatorType.BitwiseOr,
new CodeFieldReferenceExpression (flagsType, "NonPublic")
);
bindingFlags = new CodeBinaryOperatorExpression (
bindingFlags,
CodeBinaryOperatorType.BitwiseOr,
new CodeFieldReferenceExpression (flagsType, "Instance")
);
}
开发者ID:mono,项目名称:stetic,代码行数:15,代码来源:CodeGeneratorInternalClass.cs
示例20: Serialize
public override object Serialize(IDesignerSerializationManager manager, object value)
{
CodeExpression left = null;
using (CodeDomSerializerBase.TraceScope("EnumCodeDomSerializer::Serialize"))
{
Enum[] enumArray;
if (!(value is Enum))
{
return left;
}
bool flag = false;
TypeConverter converter = TypeDescriptor.GetConverter(value);
if ((converter != null) && converter.CanConvertTo(typeof(Enum[])))
{
enumArray = (Enum[]) converter.ConvertTo(value, typeof(Enum[]));
flag = enumArray.Length > 1;
}
else
{
enumArray = new Enum[] { (Enum) value };
flag = true;
}
CodeTypeReferenceExpression targetObject = new CodeTypeReferenceExpression(value.GetType());
TypeConverter converter2 = new EnumConverter(value.GetType());
foreach (Enum enum2 in enumArray)
{
string str = (converter2 != null) ? converter2.ConvertToString(enum2) : null;
CodeExpression right = !string.IsNullOrEmpty(str) ? new CodeFieldReferenceExpression(targetObject, str) : null;
if (right != null)
{
if (left == null)
{
left = right;
}
else
{
left = new CodeBinaryOperatorExpression(left, CodeBinaryOperatorType.BitwiseOr, right);
}
}
}
if ((left != null) && flag)
{
left = new CodeCastExpression(value.GetType(), left);
}
}
return left;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:47,代码来源:EnumCodeDomSerializer.cs
注:本文中的System.CodeDom.CodeTypeReferenceExpression类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论