当前位置: 首页>>代码示例>>C#>>正文


C# this.As方法代码示例

本文整理汇总了C#中this.As方法的典型用法代码示例。如果您正苦于以下问题:C# this.As方法的具体用法?C# this.As怎么用?C# this.As使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在this的用法示例。


在下文中一共展示了this.As方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetMemberType

        public static Type GetMemberType(this MemberInfo member)
        {
            if (member is FieldInfo) return member.As<FieldInfo>().FieldType;
            if (member is PropertyInfo) return member.As<PropertyInfo>().PropertyType;

            throw new NotSupportedException();
        }
开发者ID:jjchiw,项目名称:Marten,代码行数:7,代码来源:MemberInfoExtensions.cs

示例2: GetContentName

        public static string GetContentName(this IContent content)
        {
            if (content.Has<TitlePart>()) { return content.As<TitlePart>().Title; }
            if (content.Has<WidgetPart>()) { return content.As<WidgetPart>().Title; }
            if (content.Has<UserPart>()) { return content.As<UserPart>().UserName; }
            if (content.Has<WidgetPart>()) { return content.As<WidgetPart>().Title; }
            if (content.Has<LayerPart>()) { return content.As<LayerPart>().Name; }

            return "Unknown";
        }
开发者ID:arheom,项目名称:Glimpse.Orchard,代码行数:10,代码来源:ContentExtensions.cs

示例3: GetComponentsHandlerOrder

        public static string GetComponentsHandlerOrder(this IProductElement endpoint)
        {
            var sb = new StringBuilder();
            var app = endpoint.Root.As<NServiceBusStudio.IApplication>();
            var endpoints = app.Design.Endpoints.GetAll();
            var sourceComponents = (endpoint.As<IToolkitInterface>() as IAbstractEndpoint).EndpointComponents.AbstractComponentLinks.OrderBy(o => o.Order);
            var components = sourceComponents.Select(ac => ac.ComponentReference.Value)
                                       .Where(c => c.Subscribes.ProcessedCommandLinks.Any() || c.Subscribes.SubscribedEventLinks.Any())
                                       .Select(cmp => HandlerTypeFromComponent(cmp));

            // Add authentication first if needed
            if (app.HasAuthentication && (endpoint.As<IToolkitInterface>() as IAbstractEndpoint).Project != null)
            {
                components = new string[] { string.Format("{0}.Infrastructure.Authentication", (endpoint.As<IToolkitInterface>() as IAbstractEndpoint).Project.Data.RootNamespace) }.Union(components);
            }

            ////
            if (components.Count() > 1)
            {
                sb.Append(@"
            public void SpecifyOrder(Order order)
            {
            order.Specify(");

                int pos = 1;
                foreach (var c in components)
                {
                    if (pos == 1)
                    {
                        sb.AppendFormat("First<{0}>", c);
                    }
                    else if (pos == 2)
                    {
                        sb.AppendFormat(".Then<{0}>()", c);
                    }
                    else
                    {
                        sb.AppendFormat(".AndThen<{0}>()", c);
                    }
                    pos++;
                }
                sb.Append(@");
            }");
            }

            ////

            return sb.ToString();
        }
开发者ID:slamj1,项目名称:ServiceMatrix,代码行数:49,代码来源:GenerateComponentsHandlerOrder.cs

示例4: GetMemberType

        public static Type GetMemberType(this MemberInfo member)
        {
            Type rawType = null;

            if (member is FieldInfo)
            {
                rawType = member.As<FieldInfo>().FieldType;
            }
            if (member is PropertyInfo)
            {
                rawType = member.As<PropertyInfo>().PropertyType;
            }

            return rawType.IsNullable() ? rawType.GetInnerTypeFromNullable() : rawType;
        }
开发者ID:jimbono,项目名称:marten,代码行数:15,代码来源:ReflectionExtensions.cs

示例5: AsTable

 public static TableGrammar AsTable(this IGrammar inner, string title, string leafName)
 {
     return new TableGrammar(inner.As<IGrammarWithCells>(), leafName)
     {
         LabelName = title
     };
 }
开发者ID:adymitruk,项目名称:storyteller,代码行数:7,代码来源:GrammarExtensions.cs

示例6: Build

        /// <summary>
        /// Starts a build of the solution.
        /// </summary>
        public static Task<bool> Build(this ISolutionNode solution)
        {
            var sln = solution.As<EnvDTE.Solution>();
            if (sln == null)
                throw new ArgumentException(Strings.ISolutionNodeExtensions.BuildNotSupported);

            return System.Threading.Tasks.Task.Factory.StartNew<bool>(() =>
            {
                var mre = new ManualResetEventSlim();
                var events = sln.DTE.Events.BuildEvents;
                EnvDTE._dispBuildEvents_OnBuildDoneEventHandler done = (scope, action) => mre.Set();
                events.OnBuildDone += done;
                try
                {
                    // Let build run async.
                    sln.SolutionBuild.Build(false);

                    // Wait until it's done.
                    mre.Wait();

                    // LastBuildInfo == # of projects that failed to build.
                    return sln.SolutionBuild.LastBuildInfo == 0;
                }
                catch (Exception ex)
                {
                    tracer.Error(ex, Strings.ISolutionNodeExtensions.BuildException);
                    return false;
                }
                finally
                {
                    // Cleanup handler.
                    events.OnBuildDone -= done;
                }
            }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default);
        }
开发者ID:MobileEssentials,项目名称:clide,代码行数:38,代码来源:ISolutionNodeExtensions.cs

示例7: ToGraph

        public static ServiceGraph ToGraph(this IServiceRegistry registry)
        {
            var behaviorGraph = new BehaviorGraph();
            registry.As<IConfigurationAction>().Configure(behaviorGraph);

            return behaviorGraph.Services;
        }
开发者ID:roynmoore,项目名称:fubumvc,代码行数:7,代码来源:ServiceRegistryTester.cs

示例8: DisplayName

 public static string DisplayName(this IUser user)
 { 
     var userProfilePart = user.As<UserProfilePart>();
     if (userProfilePart != null && !string.IsNullOrWhiteSpace(userProfilePart.Name)) return userProfilePart.Name;
     if (!string.IsNullOrWhiteSpace(user.Email)) return user.Email;
     return user.UserName;
 }
开发者ID:quicklogons,项目名称:quicklogons.client,代码行数:7,代码来源:IUserExtensions.cs

示例9: GetMessageConventions

        public static string GetMessageConventions(this IProductElement endpoint)
        {
            var generatedConventions = string.Empty;
            try
            {
                var app = endpoint.Root.As<NServiceBusStudio.IApplication>();

                var rootNameSpace = string.Empty;
                var applicationName = app.CodeIdentifier;
                var projectNameForInternal = app.ProjectNameInternalMessages;
                var projectNameForContracts = app.ProjectNameContracts;

                var project = endpoint.As<IAbstractEndpoint>().As<IProductElement>().GetProject();
                if (project != null)
                {
                    rootNameSpace = project.Data.RootNamespace;
                }
                generatedConventions = GetMessageConventions(rootNameSpace, applicationName, projectNameForInternal, projectNameForContracts);
            }
            catch (Exception ex)
            {
                //TODO: Why are we catching the exception here??
            }
            return generatedConventions;
        }
开发者ID:nulltoken,项目名称:ServiceMatrix,代码行数:25,代码来源:GenerateMessageConventions.cs

示例10: GetMessageConventions

        public static string GetMessageConventions(this IProductElement endpoint)
        {
            var generatedConventions = string.Empty;
            try
            {
                var app = endpoint.Root.As<IApplication>();

                var rootNameSpace = string.Empty;
                var applicationName = app.InstanceName;
                var projectNameForInternal = app.ProjectNameInternalMessages;
                var projectNameForContracts = app.ProjectNameContracts;

                var project = endpoint.As<IAbstractEndpoint>().As<IProductElement>().GetProject();
                if (project != null)
                {
                    rootNameSpace = project.Data.RootNamespace;
                }

                generatedConventions =
                    app.TargetNsbVersion == TargetNsbVersion.Version4
                    ? GetMessageConventionsV4(rootNameSpace, applicationName, projectNameForInternal, projectNameForContracts)
                    : GetMessageConventionsV5(rootNameSpace, applicationName, projectNameForInternal, projectNameForContracts);
            }
            catch (Exception ex)
            {
                //TODO: Why are we catching the exception here??
            }

            return generatedConventions;
        }
开发者ID:slamj1,项目名称:ServiceMatrix,代码行数:30,代码来源:GenerateMessageConventions.cs

示例11: ShouldBeRangeVariableToken

 public static AndConstraint<RangeVariableToken> ShouldBeRangeVariableToken(this QueryToken token, string expectedName)
 {
     token.Should().BeOfType<RangeVariableToken>();
     var parameterQueryToken = token.As<RangeVariableToken>();
     parameterQueryToken.Kind.Should().Be(QueryTokenKind.RangeVariable);
     parameterQueryToken.Name.Should().Be(expectedName);
     return new AndConstraint<RangeVariableToken>(parameterQueryToken);
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:8,代码来源:TokenAssertions.cs

示例12: ShouldBeUnaryOperatorQueryToken

 public static AndConstraint<UnaryOperatorToken> ShouldBeUnaryOperatorQueryToken(this QueryToken token, UnaryOperatorKind expectedOperatorKind)
 {
     token.Should().BeOfType<UnaryOperatorToken>();
     var propertyAccessQueryToken = token.As<UnaryOperatorToken>();
     propertyAccessQueryToken.Kind.Should().Be(QueryTokenKind.UnaryOperator);
     propertyAccessQueryToken.OperatorKind.Should().Be(expectedOperatorKind);
     return new AndConstraint<UnaryOperatorToken>(propertyAccessQueryToken);
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:8,代码来源:TokenAssertions.cs

示例13: IsSynchronous

 /// <summary>
 /// indicates the task is synchronous
 /// </summary>
 /// <param name="task"></param>
 /// <returns></returns>
 public static ISynchronousDecoration IsSynchronous(this ITask task)
 {
     Condition.Requires(task).IsNotNull();
     var rv =  task.As<SynchronousDecoration>();
     if (rv == null)
         rv = new SynchronousDecoration(task);
     return rv;
 }
开发者ID:Piirtaa,项目名称:Decoratid,代码行数:13,代码来源:SynchronousDecoration.cs

示例14: ShouldBeEndPathToken

 public static AndConstraint<EndPathToken> ShouldBeEndPathToken(this QueryToken token, string expectedName)
 {
     token.Should().BeOfType<EndPathToken>();
     var propertyAccessQueryToken = token.As<EndPathToken>();
     propertyAccessQueryToken.Kind.Should().Be(QueryTokenKind.EndPath);
     propertyAccessQueryToken.Identifier.Should().Be(expectedName);
     return new AndConstraint<EndPathToken>(propertyAccessQueryToken);
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:8,代码来源:TokenAssertions.cs

示例15: IsAsynchronous

 /// <summary>
 /// Decoration that flags a task as being asynchronous and provides the conditions needed to trigger completion and error.
 /// Automatically decorates with TriggerConditions.
 /// </summary>
 /// <param name="task"></param>
 /// <returns></returns>
 public static IAsynchronousDecoration IsAsynchronous(this ITask task, ICondition markCompleteCondition, ICondition markErrorCondition)
 {
     Condition.Requires(task).IsNotNull();
     var rv = task.As<AsynchronousDecoration>();
     if (rv == null)
         rv = new AsynchronousDecoration(task, markCompleteCondition, markErrorCondition);
     return rv;
 }
开发者ID:Piirtaa,项目名称:Decoratid,代码行数:14,代码来源:AsynchronousDecoration.cs


注:本文中的this.As方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。