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


C# Object.ThrowIfNull方法代码示例

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


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

示例1: RefEquals

        /// <summary>
        ///     Determines whether the specified objects instances are the same instance.
        /// </summary>
        /// <exception cref="ArgumentNullException">The first object can not be null.</exception>
        /// <exception cref="ArgumentNullException">The second object can not be null.</exception>
        /// <param name="obj0">The first object to compare.</param>
        /// <param name="obj1">The second object  to compare.</param>
        /// <returns>Returns true if if the objects are the same instance.</returns>
        public static Boolean RefEquals( this Object obj0, Object obj1 )
        {
            obj0.ThrowIfNull( nameof( obj0 ) );
            obj1.ThrowIfNull( nameof( obj1 ) );

            return ReferenceEquals( obj0, obj1 );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:15,代码来源:Object.ReferenceEquals.cs

示例2: WireAll

        /// <summary>
        /// Wires up an entire object according to its usage of CommandWirerAttributes
        /// </summary>
        /// <param name="toWire"></param>
        /// <returns></returns>
        public static IList<CommandWirer> WireAll(Object toWire)
        {
            toWire.ThrowIfNull ("toWire");

            var toWireType = toWire.GetType ();

            var helperMap = new Dictionary<String, CommandWirer> ();

            foreach (var prop in
                toWireType.GetProperties (BindingFlags.Public | BindingFlags.Instance)
                .Union (toWireType.GetProperties (BindingFlags.NonPublic | BindingFlags.Instance))
                .Union (toWireType.GetProperties (BindingFlags.Public | BindingFlags.Static))
                .Union (toWireType.GetProperties (BindingFlags.NonPublic | BindingFlags.Static)))
            {
                foreach (var attr in prop.GetCustomAttributes (typeof (CommandWirerAttribute), true).Cast<CommandWirerAttribute> ())
                {
                    attr.SetKeyFromMethodName (prop.Name);

                    CommandWirer helper;
                    if (!helperMap.TryGetValue (attr.Key, out helper))
                        helperMap[attr.Key] = helper = new CommandWirer { Key = attr.Key, InvokeOn = toWire };

                    attr.Configure (helper, prop);
                }
            }

            foreach (var method in
                toWireType.GetMethods (BindingFlags.Public | BindingFlags.Instance)
                .Union (toWireType.GetMethods (BindingFlags.NonPublic | BindingFlags.Instance))
                .Union (toWireType.GetMethods (BindingFlags.Public | BindingFlags.Static))
                .Union (toWireType.GetMethods (BindingFlags.NonPublic | BindingFlags.Static)))
            {
                foreach (var attr in method.GetCustomAttributes (typeof (CommandWirerAttribute), true).Cast<CommandWirerAttribute> ())
                {
                    attr.SetKeyFromMethodName (method.Name);

                    CommandWirer helper;
                    if (!helperMap.TryGetValue (attr.Key, out helper))
                        helperMap[attr.Key] = helper = new CommandWirer { Key = attr.Key };

                    attr.Configure (helper, method);
                }
            }

            foreach (var helper in helperMap.Values)
                helper.Wire ();

            return helperMap.Values.ToList ();
        }
开发者ID:philchuang,项目名称:MvvmCommandWirer,代码行数:54,代码来源:CommandWirer.cs

示例3: ThrowIfNull_SetNotNull_Success

 public void ThrowIfNull_SetNotNull_Success()
 {
     object obj = new Object();
     obj.ThrowIfNull("obj");
 }
开发者ID:dminik,项目名称:AddressProcessor,代码行数:5,代码来源:ExtensionsTests.cs


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