Example #1
0
        public PackageRuleHandler(ITargetFrameworkProvider targetFrameworkProvider)
        {
            Requires.NotNull(targetFrameworkProvider, nameof(targetFrameworkProvider));

            TargetFrameworkProvider = targetFrameworkProvider;
        }
Example #2
0
        public override void SetFileAttributes(IFileInfo file, FileAttributes fileAttributes)
        {
            Requires.NotNull("file", file);

            FileWrapper.Instance.SetAttributes(GetActualPath(file), fileAttributes);
        }
 /// <summary>
 /// <para>Initializes a new instance of the <see cref="System.Fabric.Description.ServiceHealthQueryDescription" /> class.</para>
 /// </summary>
 /// <param name="serviceName">
 /// <para>The service name. Cannot be null.</para>
 /// </param>
 /// <exception cref="System.ArgumentNullException">
 /// <para>A null value was passed in for a required parameter.</para>
 /// </exception>
 public ServiceHealthQueryDescription(Uri serviceName)
 {
     Requires.Argument <Uri>("serviceName", serviceName).NotNull();
     this.ServiceName = serviceName;
 }
        public OperationDataFactoryWrapper(NativeRuntime.IOperationDataFactory operationDataFactory)
        {
            Requires.Argument("operationDataFactory", operationDataFactory).NotNull();

            this.operationDataFactory = operationDataFactory;
        }
Example #5
0
        /// <summary>
        /// This is the core to find the continuation delegate(s) inside the given async state machine.
        /// The chain of objects is like this: async state machine -> async method builder -> task -> continuation object -> action.
        /// </summary>
        /// <remarks>
        /// There are 3 types of "async method builder": AsyncVoidMethodBuilder, AsyncTaskMethodBuilder, AsyncTaskMethodBuilder&lt;T&gt;.
        /// We don't cover AsyncVoidMethodBuilder as it is used rarely and it can't be awaited either;
        /// AsyncTaskMethodBuilder is a wrapper on top of AsyncTaskMethodBuilder&lt;VoidTaskResult&gt;.
        /// </remarks>
        private static IEnumerable <Delegate> FindContinuationDelegates(IAsyncStateMachine stateMachine)
        {
            Requires.NotNull(stateMachine, nameof(stateMachine));

            var builder = GetStateMachineFieldValueOnSuffix(stateMachine, "__builder");

            if (builder == null)
            {
                yield break;
            }

            var task = GetFieldValue(builder, "m_task");

            if (task == null)
            {
                // Probably this builder is an instance of "AsyncTaskMethodBuilder", so we need to get its inner "AsyncTaskMethodBuilder<VoidTaskResult>"
                builder = GetFieldValue(builder, "m_builder");
                if (builder != null)
                {
                    task = GetFieldValue(builder, "m_task");
                }
            }

            if (task == null)
            {
                yield break;
            }

            // "task" might be an instance of the type deriving from "Task", but "m_continuationObject" is a private field in "Task",
            // so we need to use "typeof(Task)" to access "m_continuationObject".
            var continuationField = typeof(Task).GetTypeInfo().GetDeclaredField("m_continuationObject");

            if (continuationField == null)
            {
                yield break;
            }

            var continuationObject = continuationField.GetValue(task);

            if (continuationObject == null)
            {
                yield break;
            }

            if (continuationObject is IEnumerable items)
            {
                foreach (var item in items)
                {
                    var action = item as Delegate ?? GetFieldValue(item, "m_action") as Delegate;
                    if (action != null)
                    {
                        yield return(action);
                    }
                }
            }
            else
            {
                var action = continuationObject as Delegate ?? GetFieldValue(continuationObject, "m_action") as Delegate;
                if (action != null)
                {
                    yield return(action);
                }
            }
        }
Example #6
0
 internal ObjectPool(Func <T> factory, int size)
 {
     Requires.Argument(size >= 1, nameof(size), "must be greater than or equal to one");
     _factory = factory;
     _items   = new Element[size - 1];
 }
 /// <summary>
 /// update an existing IP filter
 /// </summary>
 /// <param name="ipFilter">filter details</param>
 public void UpdateIPFilter(IPFilterInfo ipFilter)
 {
     Requires.NotNull("ipFilter", ipFilter);
     DataProvider.Instance().UpdateIPFilter(ipFilter.IPFilterID, ipFilter.IPAddress, ipFilter.SubnetMask, ipFilter.RuleType, UserController.Instance.GetCurrentUserInfo().UserID);
 }
Example #8
0
        protected PartDiscovery(Resolver resolver)
        {
            Requires.NotNull(resolver, nameof(resolver));

            this.Resolver = resolver;
        }
Example #9
0
 /// <summary>
 /// Checks whether an import many collection is creatable.
 /// </summary>
 internal static bool IsImportManyCollectionTypeCreateable(ImportDefinitionBinding import)
 {
     Requires.NotNull(import, nameof(import));
     return(IsImportManyCollectionTypeCreateable(import.ImportingSiteType, import.ImportingSiteTypeWithoutCollection));
 }
Example #10
0
			/// <summary>
			/// Decodes the specified value.
			/// </summary>
			/// <param name="value">The string value carried by the transport.  Guaranteed to never be null, although it may be empty.</param>
			/// <returns>The deserialized form of the given string.</returns>
			/// <exception cref="FormatException">Thrown when the string value given cannot be decoded into the required object type.</exception>
			public object Decode(string value) {
				Requires.NotNull(value, "value");
				return new Realm(value);
			}
Example #11
0
			/// <summary>
			/// Encodes the specified value as the original value that was formerly decoded.
			/// </summary>
			/// <param name="value">The value.  Guaranteed to never be null.</param>
			/// <returns>The <paramref name="value"/> in string form, ready for message transport.</returns>
			public string EncodeAsOriginalString(object value) {
				Requires.NotNull(value, "value");
				return ((Realm)value).OriginalString;
			}
Example #12
0
			/// <summary>
			/// Encodes the specified value.
			/// </summary>
			/// <param name="value">The value.  Guaranteed to never be null.</param>
			/// <returns>The <paramref name="value"/> in string form, ready for message transport.</returns>
			public string Encode(object value) {
				Requires.NotNull(value, "value");
				return value.ToString();
			}
Example #13
0
 /// <summary>
 /// Asserts that an object is of the given <see cref="Type"/>.
 /// </summary>
 /// <param name="value">The value to be tested.</param>
 /// <param name="expectedType">The expected <see cref="Type"/>.</param>
 public static void IsType(object value, Type expectedType)
 {
     Requires.NotNull(value, "value");
     TypeAssert.IsType(value, expectedType, Strings.Assertion_WrongType, expectedType, value.GetType());
 }
        /// <summary>
        /// Begins a new scope for the given <paramref name="container"/>.
        /// Services, registered using the <see cref="ThreadScopedLifestyle"/> are cached during the
        /// lifetime of that scope. The scope should be disposed explicitly.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <returns>A new <see cref="Scope"/> instance.</returns>
        /// <exception cref="ArgumentNullException">
        /// Thrown when the <paramref name="container"/> is a null reference.</exception>
        /// <example>
        /// <code lang="cs"><![CDATA[
        /// using (ThreadScopedLifestyle.BeginScope())
        /// {
        ///     var handler = (IRequestHandler)container.GetInstance(handlerType);
        ///
        ///     handler.Handle(request);
        /// }
        /// ]]></code>
        /// </example>
        public static Scope BeginScope(Container container)
        {
            Requires.IsNotNull(container, nameof(container));

            return(GetScopeManager(container).BeginScope());
        }
Example #15
0
		public virtual Requires VisitRequires (Requires node)
		{
			if (node == null)
				return null;

			node.Assertion = VisitExpression (node.Assertion);
			node.UserMessage = VisitExpression (node.UserMessage);

			return node;
		}
Example #16
0
 internal CombinedPartDiscovery(IReadOnlyList <PartDiscovery> discoveryMechanisms)
     : base(Resolver.DefaultInstance)
 {
     Requires.NotNull(discoveryMechanisms, nameof(discoveryMechanisms));
     this.discoveryMechanisms = discoveryMechanisms;
 }
            internal void CheckPrecondition(Requires req)
            {
                if (req == null) return;

                this.hasError = false;
                
                this.Current = req;
                
                this.Visit(req);
            }
Example #18
0
            public override bool IsExportFactoryType(Type type)
            {
                Requires.NotNull(type, nameof(type));

                return(this.discoveryMechanisms.Any(discovery => discovery.IsExportFactoryType(type)));
            }
Example #19
0
        public CatalogReflectionContextAttribute(Type reflectionContextType)
        {
            Requires.NotNull(reflectionContextType, "reflectionContextType");

            _reflectionContextType = reflectionContextType;
        }
Example #20
0
        /// <summary>
        /// Reflects over an assembly and produces MEF parts for every applicable type.
        /// </summary>
        /// <param name="assembly">The assembly to search for MEF parts.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>A set of generated parts.</returns>
        public Task <DiscoveredParts> CreatePartsAsync(Assembly assembly, CancellationToken cancellationToken = default(CancellationToken))
        {
            Requires.NotNull(assembly, nameof(assembly));

            return(this.CreatePartsAsync(new[] { assembly }, null, cancellationToken));
        }
 public void DeleteIPFilter(IPFilterInfo ipFilter)
 {
     Requires.PropertyNotNegative("ipFilter", "ipFilter.IPFilterID", ipFilter.IPFilterID);
     DataProvider.Instance().DeleteIPFilter(ipFilter.IPFilterID);
 }
        public DesignTimeAssemblyResolution(IUnconfiguredProjectVsServices projectVsServices)
        {
            Requires.NotNull(projectVsServices, nameof(projectVsServices));

            _projectVsServices = projectVsServices;
        }
Example #23
0
 private static string GetAwaiterId(Awaiter awaiter)
 {
     Requires.NotNull(awaiter, nameof(awaiter));
     return(awaiter.GetHashCode().ToString(CultureInfo.InvariantCulture));
 }
Example #24
0
        public CompositionExceptionDebuggerProxy(CompositionException exception)
        {
            Requires.NotNull(exception, "exception");

            this._exception = exception;
        }
Example #25
0
        public override bool IsInSync(IFileInfo file)
        {
            Requires.NotNull("file", file);

            return(Convert.ToInt32((file.LastModificationTime - GetLastModificationTime(file)).TotalSeconds) == 0);
        }
Example #26
0
        public ExternalDuplicateWithSuffixByNameAttribute(string suffix)
        {
            Requires.NotNullOrEmpty(suffix, nameof(suffix));

            this.Suffix = suffix;
        }
Example #27
0
        public FileHelpersDataReader(Type type)
        {
            Requires.NotNull(type, "type");

            this.type = type;
        }
Example #28
0
        public UserAgentHandler(ProductHeaderValue product)
        {
            Requires.ArgumentNotNull(product, nameof(product));

            _userAgentHeaderValues = GetUserAgentHeaderValues(product);
        }
Example #29
0
 /// <summary>
 /// Calculates the SHA-256 hash of the given byte range, and then hashes the resulting hash again. This is
 /// standard procedure in BitCoin. The resulting hash is in big endian form.
 /// </summary>
 internal static byte[] DoubleDigest(byte[] input)
 {
     Requires.NotNull(input, "input");
     return(DoubleDigest(input, 0, input.Length));
 }
 public AggregateDiscriminatedUnionGenerator(params IDiscriminatedUnionGenerator <T>[] innerGenerators)
 {
     Requires.NotNull(innerGenerators, nameof(innerGenerators));
     _innerGenerators = innerGenerators;
 }
Example #31
0
		public virtual void VisitRequires (Requires node)
		{
			if (node == null)
				return;

			VisitExpression (node.Assertion);
			VisitExpression (node.UserMessage);
		}
Example #32
0
 /// <summary>
 ///   Initializes a new instance.
 /// </summary>
 /// <param name="stateGraph">The state graph that should be built up.</param>
 public StateGraphBuilder(StateGraph <TExecutableModel> stateGraph)
 {
     Requires.NotNull(stateGraph, nameof(stateGraph));
     _stateGraph = stateGraph;
 }
Example #33
0
            public static void Transform(ExtractorVisitor parent, Property autoProp, Invariant invariant,
                out Requires req, out Ensures ens)
            {
                var makeReq = new ChangePropertyInvariantIntoRequiresEnsures(parent, autoProp);
                req = makeReq.MakeRequires(invariant.Condition);

                var makeEns = new ChangePropertyInvariantIntoRequiresEnsures(parent, autoProp);
                ens = makeEns.MakeEnsures(invariant.Condition);

                ens.SourceContext = invariant.SourceContext;
                ens.PostCondition.SourceContext = ens.SourceContext;
                ens.ILOffset = invariant.ILOffset;

                if (ens.SourceConditionText == null)
                {
                    ens.SourceConditionText = invariant.SourceConditionText;
                }

                req.SourceContext = invariant.SourceContext;
                req.Condition.SourceContext = req.SourceContext;
                req.ILOffset = invariant.ILOffset;

                if (req.SourceConditionText == null)
                {
                    req.SourceConditionText = invariant.SourceConditionText;
                }
            }
Example #34
0
        void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
        {
            Requires.NotNull(info, "info");

            GetObjectData(info, context);
        }
            private void CheckRequires(Method method, Requires requires)
            {
                // F:
                Contract.Requires(requires != null);
                Contract.Requires(method != null);

                CheckRequiresPlain(method, requires as RequiresPlain);

                var nonVisible = this.visibilityHelper.AsVisibleAs(requires.Condition, method);
                if (nonVisible != null)
                {
                    string message = "Member '" + nonVisible.FullName +
                                     "' has less visibility than the enclosing method '"
                                     + method.FullName + "'.";
                    this.HandleError(method, 1038, message, requires);
                }
            }
Example #36
0
        /// <summary>
        /// Processes operation contract statement node.
        /// </summary>
        /// <param name="node">The node.</param>
        private void Process_OperationContractStatement(dynamic node)
        {
            if (node.GetBrand() == "Ensures")
            {
                Ensures ensures = new Ensures();

                // Map source location and node to object
                ensures.AddMetaInfo(new SourceLocationInfo(node, context));
                context.AddObject(node, ensures);

                // OperationContract
                ensures.OperationContract = (OperationContract)NameContext.Current.Scope;

                // Text
                ensures.Text = node.Text;

                // Rule
                ensures.Rule = this.Process(node.Rule);
                ensures.Rule.ExpectedType = BuiltInType.Bool;
            }
            if (node.GetBrand() == "Requires")
            {
                Requires requires = new Requires();

                // Map source location and node to object
                requires.AddMetaInfo(new SourceLocationInfo(node, context));
                context.AddObject(node, requires);

                // OperationContract
                requires.OperationContract = (OperationContract)NameContext.Current.Scope;

                // Text
                requires.Text = node.Text;

                // Rule
                requires.Rule = this.Process(node.Rule);
                requires.Rule.ExpectedType = BuiltInType.Bool;

                // Otherwise
                requires.Otherwise = this.Process(node.Otherwise);
                requires.Otherwise.ExpectedType = PseudoType.Object;
            }
        }