public static bool IsSetOfKeysUp(this KeyboardState keyboardState, IEnumerable<IEnumerable<Keys>> setsOfKeys)
        {
            keyboardState.ThrowIfNull("keyboardState");
            setsOfKeys.ThrowIfNull("setsOfKeys");

            return setsOfKeys.Any(arg => AreAllKeysUp(keyboardState, arg));
        }
        public static bool AreAllKeysUp(this KeyboardState keyboardState, IEnumerable<Keys> keys)
        {
            keyboardState.ThrowIfNull("keyboardState");
            keys.ThrowIfNull("keys");

            return keys.All(keyboardState.IsKeyUp);
        }
Exemplo n.º 3
0
        public static MatchResult RouteNotMatched(IEnumerable<IRestriction> matchedRestrictions, IEnumerable<IRestriction> unmatchedRestrictions)
        {
            matchedRestrictions.ThrowIfNull("matchedRestrictions");
            unmatchedRestrictions.ThrowIfNull("unmatchedRestrictions");

            return new MatchResult(MatchResultType.RouteNotMatched, matchedRestrictions, unmatchedRestrictions, null);
        }
Exemplo n.º 4
0
        public ResponseResult GetResponse(HttpRequestBase request, IEnumerable<RouteMatchResult> routeMatchResults)
        {
            request.ThrowIfNull("request");
            routeMatchResults.ThrowIfNull("routeMatchResults");

            return ResponseResult.ResponseGenerated(Response.NotFound());
        }
        public IEnumerable<XElement> Serialize(IEnumerable<IMessagePart> parts)
        {
            parts.ThrowIfNull("parts");

            foreach (IMessagePart part in parts)
            {
                var messageColor = part as MessageColor;
                var messageLineBreak = part as MessageLineBreak;
                var messageQuestion = part as MessageQuestion;
                var messageText = part as MessageText;

                if (messageColor != null)
                {
                    yield return MessageColorSerializer.Instance.Serialize(messageColor);
                }
                else if (messageLineBreak != null)
                {
                    yield return MessageLineBreakSerializer.Instance.Serialize(messageLineBreak);
                }
                else if (messageQuestion != null)
                {
                    yield return MessageQuestionSerializer.Instance.Serialize(messageQuestion);
                }
                else if (messageText != null)
                {
                    yield return MessageTextSerializer.Instance.Serialize(messageText);
                }
                else
                {
                    throw new ArgumentException(String.Format("Unknown message part type '{0}'.", part.GetType().Name));
                }
            }
        }
Exemplo n.º 6
0
        public RouteCollection Add(IEnumerable<Route> routes)
        {
            routes.ThrowIfNull("routes");

            foreach (Route route in routes)
            {
                if (_routeIds.Contains(route.Id))
                {
                    throw new ArgumentException(String.Format("A route with ID {0} has already been added.", route.Id), "routes");
                }
                if (!_allowDuplicateRouteNames && _routeNames.Contains(route.Name))
                {
                    throw new ArgumentException(String.Format("A route named '{0}' has already been added.", route.Name), "routes");
                }

                _routes.Add(route);
                _routeNames.Add(route.Name);
                if (!_allowDuplicateRouteNames)
                {
                    _routeIds.Add(route.Id);
                }
            }

            return this;
        }
Exemplo n.º 7
0
        public Message(
			Guid id,
			string name,
			string description,
			Color backgroundColor,
			IEnumerable<IMessagePart> parts,
			EventHandlerCollection eventHandlerCollection = null)
        {
            name.ThrowIfNull("name");
            description.ThrowIfNull("description");
            parts.ThrowIfNull("parts");

            parts = parts.ToArray();

            IMessagePart question = parts.SingleOrDefault(arg => arg is MessageMananger);

            if (question != null && parts.Last() != question)
            {
                throw new ArgumentException("When a MessageQuestion is present, it must be the last part.", "parts");
            }

            _id = id;
            Name = name;
            Description = description;
            _backgroundColor = backgroundColor;
            _parts = parts;
            _eventHandlerCollection = eventHandlerCollection;
        }
        public IEnumerable<Routing.Route> GetRoutes(IGuidFactory guidFactory, IUrlResolver urlResolver, IHttpRuntime httpRuntime, string diagnosticsRelativeUrl, IEnumerable<IDiagnosticConfiguration> configurations)
        {
            guidFactory.ThrowIfNull("guidFactory");
            urlResolver.ThrowIfNull("urlResolver");
            diagnosticsRelativeUrl.ThrowIfNull("diagnosticsUrl");
            configurations.ThrowIfNull("configurations");

            string diagnosticsUrl = urlResolver.Absolute(diagnosticsRelativeUrl);

            yield return DiagnosticRouteHelper.Instance.GetViewRoute<DiagnosticsView>(
                "Diagnostics Home View",
                guidFactory,
                diagnosticsRelativeUrl,
                ResponseResources.Diagnostics,
                DiagnosticsViewNamespaces,
                httpRuntime,
                view =>
                    {
                        view.UrlResolver = urlResolver;
                        AddLinks(view, diagnosticsUrl, configurations);
                    });
            yield return DiagnosticRouteHelper.Instance.GetStylesheetRoute("Diagnostics Common CSS", guidFactory, diagnosticsRelativeUrl + "/css/common", ResponseResources.common, httpRuntime);
            yield return DiagnosticRouteHelper.Instance.GetStylesheetRoute("Diagnostics Reset CSS", guidFactory, diagnosticsRelativeUrl + "/css/reset", ResponseResources.reset, httpRuntime);
            yield return DiagnosticRouteHelper.Instance.GetJavaScriptRoute("Diagnostics jQuery JS", guidFactory, diagnosticsRelativeUrl + "/js/jquery", ResponseResources.jquery_1_8_2_min, httpRuntime);

            foreach (IDiagnosticConfiguration arg in configurations)
            {
                foreach (Routing.Route route in arg.GetRoutes(guidFactory, urlResolver, httpRuntime, diagnosticsRelativeUrl))
                {
                    yield return route;
                }
            }
        }
		public AspNetDiagnosticConfiguration(
			Type cacheType,
			IEnumerable<Type> requestFilterTypes,
			IEnumerable<Type> responseGeneratorTypes,
			IEnumerable<Type> responseHandlerTypes,
			IEnumerable<Type> errorHandlerTypes,
			Type antiCsrfCookieManagerType = null,
			Type antiCsrfNonceValidatorType = null,
			Type antiCsrfResponseGeneratorType = null)
		{
			cacheType.ThrowIfNull("cacheType");
			requestFilterTypes.ThrowIfNull("requestFilterTypes");
			responseGeneratorTypes.ThrowIfNull("responseGeneratorTypes");
			responseHandlerTypes.ThrowIfNull("responseHandlerTypes");
			errorHandlerTypes.ThrowIfNull("errorHandlerTypes");

			_cacheType = cacheType;
			_requestFilterTypes = requestFilterTypes.ToArray();
			_responseGeneratorTypes = responseGeneratorTypes.ToArray();
			_responseHandlerTypes = responseHandlerTypes.ToArray();
			_errorHandlerTypes = errorHandlerTypes.ToArray();
			_antiCsrfCookieManagerType = antiCsrfCookieManagerType;
			_antiCsrfNonceValidatorType = antiCsrfNonceValidatorType;
			_antiCsrfResponseGeneratorType = antiCsrfResponseGeneratorType;
		}
Exemplo n.º 10
0
        public static MatchResult RouteMatched(IEnumerable<IRestriction> matchedRestrictions, string cacheKey)
        {
            matchedRestrictions.ThrowIfNull("matchedRestrictions");
            cacheKey.ThrowIfNull("cacheKey");

            return new MatchResult(MatchResultType.RouteMatched, matchedRestrictions, null, cacheKey);
        }
Exemplo n.º 11
0
		public void Populate(
			Type cacheType,
			IEnumerable<Type> requestFilterTypes,
			IEnumerable<Type> responseGeneratorTypes,
			IEnumerable<Type> responseHandlerTypes,
			IEnumerable<Type> errorHandlerTypes,
			Type antiCsrfCookieManagerType,
			Type antiCsrfNonceValidatorType,
			Type antiCsrfResponseGeneratorType)
		{
			cacheType.ThrowIfNull("cacheType");
			requestFilterTypes.ThrowIfNull("requestFilterTypes");
			responseGeneratorTypes.ThrowIfNull("responseGeneratorTypes");
			responseHandlerTypes.ThrowIfNull("responseHandlerTypes");
			errorHandlerTypes.ThrowIfNull("errorHandlerTypes");

			CacheType = cacheType;
			RequestFilterTypes = requestFilterTypes;
			ResponseGeneratorTypes = responseGeneratorTypes;
			ResponseHandlerTypes = responseHandlerTypes;
			ErrorHandlerTypes = errorHandlerTypes;
			AntiCsrfCookieManagerType = antiCsrfCookieManagerType;
			AntiCsrfNonceValidatorType = antiCsrfNonceValidatorType;
			AntiCsrfResponseGeneratorType = antiCsrfResponseGeneratorType;
		}
Exemplo n.º 12
0
		public AspNetHttpHandler(
			IRouteCollection routes,
			ICache cache,
			IEnumerable<IResponseGenerator> responseGenerators,
			IEnumerable<IResponseHandler> responseHandlers,
			IAntiCsrfCookieManager antiCsrfCookieManager,
			IAntiCsrfNonceValidator antiCsrfNonceValidator,
			IAntiCsrfResponseGenerator antiCsrfResponseGenerator)
		{
			routes.ThrowIfNull("routes");
			cache.ThrowIfNull("cache");
			responseGenerators.ThrowIfNull("responseGenerators");
			responseHandlers.ThrowIfNull("responseHandlers");
			antiCsrfCookieManager.ThrowIfNull("antiCsrfSessionManager");
			antiCsrfNonceValidator.ThrowIfNull("antiCsrfTokenValidator");
			antiCsrfResponseGenerator.ThrowIfNull("antiCsrfResponseGenerator");

			_routes = routes;
			_cache = cache;
			_responseGenerators = responseGenerators.ToArray();
			_responseHandlers = responseHandlers.ToArray();
			_antiCsrfCookieManager = antiCsrfCookieManager;
			_antiCsrfNonceValidator = antiCsrfNonceValidator;
			_antiCsrfResponseGenerator = antiCsrfResponseGenerator;
		}
Exemplo n.º 13
0
        public RouteCollection Add(IEnumerable<Route> routes)
        {
            routes.ThrowIfNull("routes");

            foreach (Route route in routes)
            {
                if (_routesById.ContainsKey(route.Id))
                {
                    throw new ArgumentException(String.Format("A route with ID {0} has already been added.", route.Id), "routes");
                }
                if (!_allowDuplicateRouteNames && _routesByName.ContainsKey(route.Name))
                {
                    throw new ArgumentException(String.Format("A route named '{0}' has already been added.", route.Name), "routes");
                }

                _routesById.Add(route.Id, route);

                List<Route> routeList;

                if (!_routesByName.TryGetValue(route.Name, out routeList))
                {
                    routeList = new List<Route>();
                    _routesByName.Add(route.Name, routeList);
                }
                routeList.Add(route);
            }

            return this;
        }
Exemplo n.º 14
0
        public Task<ResponseResult> GetResponseAsync(HttpContextBase context, IEnumerable<RouteMatchResult> routeMatchResults)
        {
            context.ThrowIfNull("context");
            routeMatchResults.ThrowIfNull("routeMatchResults");

            return ResponseResult.ResponseGenerated(new Response().NotFound()).AsCompletedTask();
        }
Exemplo n.º 15
0
        public void DecorateClass(IResource resource,
                                  string className,
                                  CodeTypeDeclaration resourceClass,
                                  ResourceClassGenerator generator,
                                  string serviceClassName,
                                  IEnumerable<IResourceDecorator> allDecorators)
        {
            resource.ThrowIfNull("resource");
            className.ThrowIfNull("className");
            resourceClass.ThrowIfNull("resourceClass");
            generator.ThrowIfNull("generator");
            serviceClassName.ThrowIfNull("serviceClassName");
            allDecorators.ThrowIfNull("allDecorators");

            if (!resource.IsServiceResource) // Only add subresources of normal resources, not the root resource.
            {
                // Add all subresources.
                foreach (IResource subresource in resource.Resources.Values)
                {
                    // Consider all members in the current class as invalid names.
                    var forbiddenWords = from CodeTypeMember m in resourceClass.Members select m.Name;

                    // Generate and add the subresource.
                    CodeTypeDeclaration decl = GenerateSubresource(
                        subresource, serviceClassName, allDecorators, generator.RequestGenerator,
                        generator.ContainerGenerator, forbiddenWords);
                    resourceClass.Members.Add(decl);
                }
            }
        }
Exemplo n.º 16
0
		public ModelMapper(Func<Type, bool> parameterTypeMatchDelegate, IEnumerable<IModelPropertyMapper> propertyMappers)
		{
			parameterTypeMatchDelegate.ThrowIfNull("parameterTypeMatchDelegate");
			propertyMappers.ThrowIfNull("propertyMappers");

			_parameterTypeMatchDelegate = parameterTypeMatchDelegate;
			_modelPropertyMappers = propertyMappers.ToArray();
		}
        protected JuniorRouteApplicationConfiguration SetRequestFilters(IEnumerable<IRequestFilter> filters)
        {
            filters.ThrowIfNull("filters");

            _requestFilters = filters.ToArray();

            return this;
        }
		protected JuniorRouteApplicationConfiguration SetErrorHandlers(IEnumerable<IErrorHandler> handlers)
		{
			handlers.ThrowIfNull("handlers");

			_errorHandlers = handlers.ToArray();

			return this;
		}
 public GoogleSchemaGenerator(IEnumerable<ISchemaDecorator> decorators, string schemaNamespace)
 {
     decorators.ThrowIfNull("decorators");
     schemaNamespace.ThrowIfNull("schemaNamespace");
     this.decorators = new List<ISchemaDecorator>(decorators).AsReadOnly();
     this.schemaNamespace = schemaNamespace;
     this.implementationDetailsGenerator = new ImplementationDetailsGenerator();
 }
        public ResponseMethodReturnTypeMapper(IEnumerable<IParameterMapper> mappers, IEnumerable<IMappedDelegateContextFactory> contextFactories)
        {
            mappers.ThrowIfNull("mappers");
            contextFactories.ThrowIfNull("contextFactories");

            _parameterMappers.AddRange(mappers);
            _contextFactories = contextFactories;
        }
Exemplo n.º 21
0
        public Bundle AddAssets(IEnumerable<IAsset> assets)
        {
            assets.ThrowIfNull("assets");

            _assets.AddRange(assets);

            return this;
        }
Exemplo n.º 22
0
        public static Bundle FromFiles(IEnumerable<string> relativePaths)
        {
            relativePaths.ThrowIfNull("relativePaths");

            var bundle = new Bundle();

            return bundle.Files(relativePaths);
        }
Exemplo n.º 23
0
 public FileToWrite(string @namespace, IEnumerable<string> lines)
 {
     if (string.IsNullOrWhiteSpace(@namespace))
     {
         throw new ArgumentNullException(nameof(@namespace));
     }
     this.Namespace = @namespace;
     this.Lines = lines.ThrowIfNull(nameof(lines));
 }
        /// <summary>
        /// Calls Validate method on all validators
        /// </summary>
        /// <param name="validators">The validators</param>
        /// <exception cref="ArgumentNullException"/>
        public static void ValidateAll(IEnumerable<IValidator> validators)
        {
            validators.ThrowIfNull();

            foreach (var validator in validators)
            {
                validator.Validate();
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ITunesDirectoryInfo"/> class.
        /// The directory will be the last level of the directory structure and contains the files.
        /// </summary>
        /// <param name="albumName">The name of the album.</param>
        /// <param name="files">The files that are contained in this directory.</param>
        /// <param name="parent">The parent.</param>
        public ITunesDirectoryInfo(string albumName, IEnumerable<IFileInfo> files, ITunesDirectoryInfo parent)
            : this(parent)
        {
            albumName.ThrowIfNull(() => albumName);
            files.ThrowIfNull(() => files);

            this.name = albumName;
            this.files = files;
        }
Exemplo n.º 26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ITunesDirectoryInfo"/> class.
        /// The directory will be the middle level of the directory structure and contains the album directories.
        /// </summary>
        /// <param name="artistName">The name of the artist.</param>
        /// <param name="directories">The directories that are contained in this directory.</param>
        /// <param name="parent">The parent.</param>
        public ITunesDirectoryInfo(string artistName, IEnumerable<ITunesDirectoryInfo> directories, ITunesDirectoryInfo parent)
            : this(parent)
        {
            artistName.ThrowIfNull(() => artistName);
            directories.ThrowIfNull(() => directories);

            this.name = artistName;
            this.directories = directories;
        }
Exemplo n.º 27
0
		public ModelMapper(IContainer container, Func<Type, bool> parameterTypeMatchDelegate, IEnumerable<IModelPropertyMapper> propertyMappers)
		{
			container.ThrowIfNull("container");
			parameterTypeMatchDelegate.ThrowIfNull("parameterTypeMatchDelegate");
			propertyMappers.ThrowIfNull("propertyMappers");

			_container = container;
			_parameterTypeMatchDelegate = parameterTypeMatchDelegate;
			_modelPropertyMappers = propertyMappers.ToArray();
		}
Exemplo n.º 28
0
        public void Populate(Type cacheType, IEnumerable<Type> responseGeneratorTypes, IEnumerable<Type> responseHandlerTypes)
        {
            cacheType.ThrowIfNull("cacheType");
            responseGeneratorTypes.ThrowIfNull("responseGeneratorTypes");
            responseHandlerTypes.ThrowIfNull("responseHandlerTypes");

            CacheType = cacheType;
            ResponseGeneratorTypes = responseGeneratorTypes;
            ResponseHandlerTypes = responseHandlerTypes;
        }
        public AspNetDiagnosticConfiguration(Type cacheType, IEnumerable<Type> responseGeneratorTypes, IEnumerable<Type> responseHandlerTypes)
        {
            cacheType.ThrowIfNull("cacheType");
            responseGeneratorTypes.ThrowIfNull("responseGeneratorTypes");
            responseHandlerTypes.ThrowIfNull("responseHandlerTypes");

            _cacheType = cacheType;
            _responseGeneratorTypes = responseGeneratorTypes.ToArray();
            _responseHandlerTypes = responseHandlerTypes.ToArray();
        }
Exemplo n.º 30
0
        private TeHeader(string tCoding, decimal? qvalue, IEnumerable<Parameter> parameters)
        {
            tCoding.ThrowIfNull("tCoding");
            parameters.ThrowIfNull("parameters");

            _tCoding = tCoding;
            _parameters = parameters.ToArray();
            _qvalue = qvalue;
            _effectiveQvalue = qvalue ?? 1m;
        }
Exemplo n.º 31
0
 /// <summary>
 ///     Instantiates a regular expression that matches a sequence of consecutive characters using the specified
 ///     optional equality comparer.</summary>
 public Stringerex(IEnumerable <char> elements, IEqualityComparer <char> comparer) : base(elements.ThrowIfNull("elements").ToArray(), comparer)
 {
 }
Exemplo n.º 32
0
        public static Boolean Many <T>([NotNull][ItemCanBeNull] this IEnumerable <T> enumerable)
        {
            enumerable.ThrowIfNull(nameof(enumerable));

            return(enumerable.Count() > 1);
        }
Exemplo n.º 33
0
 /// <summary>
 /// Добавить дочерние выражения из перечисления
 /// </summary>
 /// <param name="expressions"></param>
 public void AddExpressions(IEnumerable <Expression> expressions)
 {
     expressions.ThrowIfNull("Expression can't be null");
     SubExpressions.AddRange(expressions);
 }
Exemplo n.º 34
0
        public ConcurrentHashSet(IEnumerable <T> collection)
        {
            collection.ThrowIfNull(nameof(collection));

            _set = new HashSet <T>(collection);
        }
Exemplo n.º 35
0
 /// <summary>
 /// Set multiple indices
 /// </summary>
 public PutWarmerDescriptor Indices(IEnumerable <string> indices)
 {
     indices.ThrowIfNull("indices");
     indices.ThrowIfEmpty("indices");
     return(this.Index(string.Join(",", indices)));
 }
Exemplo n.º 36
0
        public ChangeTracker(IEnumerable <IChangeEventHandler> eventHandlers)
        {
            eventHandlers.ThrowIfNull(nameof(eventHandlers));

            _eventHandlers = eventHandlers;
        }
Exemplo n.º 37
0
 public QuestionarySessionStepResult(IEnumerable <QuestionAnswer> answers)
     : base(SessionStepResultType.Successful)
 {
     Answers = answers.ThrowIfNull(nameof(answers)).ToList();
 }
Exemplo n.º 38
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="implementors">набор диагностик</param>
 public HealthCheckingService(IEnumerable <IDiagnosticImplementor> implementors)
 {
     _implementors = implementors.ThrowIfNull(nameof(implementors));
 }
Exemplo n.º 39
0
 /// <summary>Instantiates a regular expression that matches a sequence of consecutive characters.</summary>
 public Stringerex(IEnumerable <char> elements) : base(elements.ThrowIfNull("elements").ToArray(), EqualityComparer <char> .Default)
 {
 }
Exemplo n.º 40
0
        /// <summary>
        /// Add the collection of parcels to the datasource.
        /// </summary>
        /// <param name="entities"></param>
        /// <returns></returns>
        public IEnumerable <Parcel> Add(IEnumerable <Parcel> entities)
        {
            entities.ThrowIfNull(nameof(entities));
            this.User.ThrowIfNotAuthorized(Permissions.SystemAdmin, Permissions.AgencyAdmin);

            entities.ForEach((entity) =>
            {
                if (entity == null)
                {
                    throw new ArgumentNullException();
                }

                if (entity.AgencyId != 0 && !this.Context.Agencies.Local.Any(a => a.Id == entity.AgencyId))
                {
                    this.Context.Entry(entity.Agency).State = EntityState.Unchanged;
                }
                if (entity.Classification != null && !this.Context.PropertyClassifications.Local.Any(a => a.Id == entity.ClassificationId))
                {
                    this.Context.Entry(entity.Classification).State = EntityState.Unchanged;
                }

                entity.Agency         = this.Context.Agencies.Local.FirstOrDefault(a => a.Id == entity.AgencyId);
                entity.Classification = this.Context.PropertyClassifications.Local.FirstOrDefault(a => a.Id == entity.ClassificationId);

                entity.Buildings.ForEach(b =>
                {
                    this.Context.Buildings.Add(b);
                    if (b.Agency != null && !this.Context.Agencies.Local.Any(a => a.Id == b.AgencyId))
                    {
                        this.Context.Entry(b.Agency).State = EntityState.Unchanged;
                    }
                    if (b.Classification != null && !this.Context.PropertyClassifications.Local.Any(a => a.Id == b.ClassificationId))
                    {
                        this.Context.Entry(b.Classification).State = EntityState.Unchanged;
                    }
                    if (b.BuildingConstructionType != null && !this.Context.BuildingConstructionTypes.Local.Any(a => a.Id == b.BuildingConstructionTypeId))
                    {
                        this.Context.Entry(b.BuildingConstructionType).State = EntityState.Unchanged;
                    }
                    if (b.BuildingPredominateUse != null && !this.Context.BuildingPredominateUses.Local.Any(a => a.Id == b.BuildingPredominateUseId))
                    {
                        this.Context.Entry(b.BuildingPredominateUse).State = EntityState.Unchanged;
                    }
                    if (b.BuildingOccupantType != null && !this.Context.BuildingOccupantTypes.Local.Any(a => a.Id == b.BuildingOccupantTypeId))
                    {
                        this.Context.Entry(b.BuildingOccupantType).State = EntityState.Unchanged;
                    }

                    b.Agency                   = this.Context.Agencies.Local.FirstOrDefault(a => a.Id == b.AgencyId);
                    b.Classification           = this.Context.PropertyClassifications.Local.FirstOrDefault(a => a.Id == b.ClassificationId);
                    b.BuildingConstructionType = this.Context.BuildingConstructionTypes.Local.FirstOrDefault(a => a.Id == b.BuildingConstructionTypeId);
                    b.BuildingPredominateUse   = this.Context.BuildingPredominateUses.Local.FirstOrDefault(a => a.Id == b.BuildingPredominateUseId);
                    b.BuildingOccupantType     = this.Context.BuildingOccupantTypes.Local.FirstOrDefault(a => a.Id == b.BuildingOccupantTypeId);

                    b.Evaluations.ForEach(e =>
                    {
                        this.Context.BuildingEvaluations.Add(e);
                    });
                    b.Fiscals.ForEach(f =>
                    {
                        this.Context.BuildingFiscals.Add(f);
                    });

                    if (b.Address != null)
                    {
                        this.Context.Addresses.Add(b.Address);
                    }
                });

                entity.Evaluations.ForEach(e =>
                {
                    this.Context.ParcelEvaluations.Add(e);
                });
                entity.Fiscals.ForEach(f =>
                {
                    this.Context.ParcelFiscals.Add(f);
                });

                if (entity.Address != null)
                {
                    this.Context.Addresses.Add(entity.Address);
                }
            });

            this.Context.Parcels.AddRange(entities);
            this.Context.CommitTransaction();
            return(entities);
        }
Exemplo n.º 41
0
 public static IEnumerable <T> WhereNotNull <T>(this IEnumerable <T> source)
     where T : class
 {
     source.ThrowIfNull("source");
     return(source.Where(x => x != null));
 }
Exemplo n.º 42
0
 /// <summary>
 /// Creates a new instance of the <see cref="ComponentNoise"/> class.
 /// </summary>
 /// <param name="generators"></param>
 public ComponentNoise(IEnumerable <NoiseGenerator> generators)
 {
     generators.ThrowIfNull(nameof(generators));
     Generators = new NoiseGeneratorCollection(generators);
 }
Exemplo n.º 43
0
 public EyeTrackerValidationSessionStepResult(SessionStepResultType result, IEnumerable <PointDisplayTime> displayedPoints)
     : base(result)
 {
     Points = displayedPoints.ThrowIfNull(nameof(displayedPoints)).ToList();
 }
Exemplo n.º 44
0
 public static IEnumerable <T> WhereNot <T>(this IEnumerable <T> source, Predicate <T> predicate)
 {
     source.ThrowIfNull("source");
     predicate.ThrowIfNull("predicate");
     return(source.Where(x => !predicate(x)));
 }
Exemplo n.º 45
0
        /// <summary>
        /// Forcefully adds parsed content elements to this container.
        /// </summary>
        /// <param name="tile">The tile to add content to.</param>
        /// <param name="contentElements">The content elements to add.</param>
        private void AddContent(ITile tile, IEnumerable <IParsedElement> contentElements)
        {
            contentElements.ThrowIfNull(nameof(contentElements));

            // load and add tile flags and contents.
            foreach (var e in contentElements)
            {
                foreach (var attribute in e.Attributes)
                {
                    if (attribute.Name.Equals("Content"))
                    {
                        if (attribute.Value is IEnumerable <IParsedElement> elements)
                        {
                            var thingStack = new Stack <IThing>();

                            foreach (var element in elements)
                            {
                                if (element.IsFlag)
                                {
                                    // A flag is unexpected in this context.
                                    this.Logger.Warning($"Unexpected flag {element.Attributes?.First()?.Name}, ignoring.");

                                    continue;
                                }

                                IItem item = this.ItemFactory.CreateItem(new ItemCreationArguments()
                                {
                                    TypeId = (ushort)element.Id
                                });

                                if (item == null)
                                {
                                    this.Logger.Warning($"Item with id {element.Id} not found in the catalog, skipping.");

                                    continue;
                                }

                                this.SetItemAttributes(item, element.Attributes);

                                thingStack.Push(item);
                            }

                            // Add them in reversed order.
                            while (thingStack.Count > 0)
                            {
                                var thing = thingStack.Pop();

                                tile.AddContent(this.ItemFactory, thing);

                                if (thing is IContainedThing containedThing)
                                {
                                    containedThing.ParentContainer = tile;
                                }
                            }
                        }
                    }
                    else
                    {
                        // it's a flag
                        if (Enum.TryParse(attribute.Name, out TileFlag flagMatch))
                        {
                            tile.SetFlag(flagMatch);
                        }
                        else
                        {
                            this.Logger.Warning($"Unknown flag [{attribute.Name}] found on tile at location {tile.Location}.");
                        }
                    }
                }
            }
        }
Exemplo n.º 46
0
 public static IEnumerable <T> StartWith <T>(this IEnumerable <T> source, T first)
 {
     source.ThrowIfNull("source");
     return(first.Prepend(source));
 }
Exemplo n.º 47
0
 public static IEnumerable <T> Flatten <T>(this IEnumerable <IEnumerable <T> > source)
 {
     source.ThrowIfNull("source");
     return(source.SelectMany(s => s));
 }
Exemplo n.º 48
0
        public static Boolean NotAny <T>([NotNull][ItemCanBeNull] this IEnumerable <T> enumerable)
        {
            enumerable.ThrowIfNull(nameof(enumerable));

            return(!enumerable.Any());
        }
Exemplo n.º 49
0
        private void ProcessCommandLine(IEnumerable <string> commandLine)
        {
            commandLine.ThrowIfNull(nameof(commandLine));

            var commandLineArguments = commandLine as string[] ?? commandLine.ToArray();

            if (!commandLineArguments.Any())
            {
                throw new ArgumentException("Collection must have at least one element", nameof(commandLine));
            }

            var sessionManager = ServiceLocator.Instance.Get <ISessionManager>();

            var unknownCommandLine = false;
            var args = commandLineArguments.ToArray();

            var options = Parser.Default.ParseArguments <Log4NetOptions, NLogOptions>(args).MapResult(
                (Log4NetOptions o) => Tuple.Create <string, IOptions>("log4net", o),
                (NLogOptions o) => Tuple.Create <string, IOptions>("nlog", o),
                _ => Tuple.Create <string, IOptions>(string.Empty, null));

            var verb = options.Item1;

            if (string.IsNullOrWhiteSpace(options.Item1))
            {
                var filePath = commandLineArguments.FirstOrDefault();
                if (!File.Exists(filePath) || Path.GetExtension(filePath)?.ToUpper() != ".SNTL")
                {
                    unknownCommandLine = true;
                }
            }

            if (unknownCommandLine)
            {
                // TODO: command line usage dialog
                MessageBox.Show(
                    "File does not exist or is not a Sentinel session file.",
                    "Sentinel",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
                return;
            }

            RemoveBindingReferences();

            switch (verb)
            {
            case "nlog":
                CreateDefaultNLogListener((NLogOptions)options.Item2, sessionManager);
                break;

            case "log4net":
                CreateDefaultLog4NetListener((Log4NetOptions)options.Item2, sessionManager);
                break;

            default:
                sessionManager.LoadSession(commandLineArguments.FirstOrDefault());
                break;
            }

            BindViewToViewModel();

            var frame = ServiceLocator.Instance.Get <IWindowFrame>();

            // Add to the tab control.
            var newTab = new TabItem {
                Header = sessionManager.Name, Content = frame
            };

            tabControl.Items.Add(newTab);
            tabControl.SelectedItem = newTab;
        }
Exemplo n.º 50
0
        public RandomElementGenerator(IEnumerable <T> list, IRandom random)
        {
            list.ThrowIfNull("list");

            generator = new ListSelectorGenerator <T>(list, new UniformIntGenerator(list.Count(), random));
        }
Exemplo n.º 51
0
        public override void UpdateBlocks(IEnumerable <ToplistBlock> blocks)
        {
            blocks.ThrowIfNull(nameof(blocks));

            base.UpdateBlocks(blocks);
        }
        /// <summary>
        /// Creates and adds a public auto-property (property and backening field) to the class.
        /// Add the ability to add base class (using <code>implementedInterface</code>
        /// to the specified propterty and specified <code>attributes</code>.
        /// </summary>
        /// <param name="name">Suggested name for the property</param>
        /// <param name="summaryComment">The property's summary</param>
        /// <param name="propertyType">The proeprty's type</param>
        /// <param name="usedNames">A list of already in used names, the final name can't used one of those</param>
        /// <param name="readOnly">Should a setter be generated?</param>
        /// <param name="implementedInterface">The property's ImplementationTypes</param>
        /// <param name="attributes">The proeprty's Attributes (default is <code>MemberAttributes.Public</code></param>
        public static CodeTypeMemberCollection CreateAutoProperty(string name,
                                                                  string summaryComment,
                                                                  CodeTypeReference propertyType,
                                                                  IEnumerable <string> usedNames,
                                                                  bool readOnly,
                                                                  Type implementedInterface = null,
                                                                  Nullable <MemberAttributes> attributes = null)
        {
            // Validate parameters.
            name.ThrowIfNullOrEmpty("name");
            propertyType.ThrowIfNull("propertyType");
            usedNames.ThrowIfNull("usedNames");

            // Generate the property name.
            string propertyName = GeneratorUtils.GetPropertyName(name, usedNames);

            // Create backening field.
            var    field        = CreateBackingField(name, propertyType, usedNames.Concat(propertyName));
            string fieldName    = field.Name;
            var    fieldNameRef = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), fieldName);

            // Add property.
            var property = new CodeMemberProperty();

            property.Name = propertyName;
            if (attributes.HasValue)
            {
                property.Attributes = attributes.Value;
            }
            else
            {
                property.Attributes = MemberAttributes.Public; // default is public
            }
            if (implementedInterface != null)
            {
                property.ImplementationTypes.Add(implementedInterface);
            }

            if (summaryComment.IsNotNullOrEmpty())
            {
                property.Comments.Add(new CodeCommentStatement("<summary>" + summaryComment + "</summary>", true));
            }
            property.Type   = propertyType;
            property.HasGet = true;
            property.HasSet = !readOnly;

            // Add getter and setter.
            property.GetStatements.Add(new CodeMethodReturnStatement(fieldNameRef));
            if (property.HasSet)
            {
                property.SetStatements.Add(
                    new CodeAssignStatement(fieldNameRef, new CodePropertySetValueReferenceExpression()));
            }

            // Return the result.
            var col = new CodeTypeMemberCollection();

            col.Add(field);
            col.Add(property);
            return(col);
        }
Exemplo n.º 53
0
        public SpriteGroup(IEnumerable <Sprite> sprites)
        {
            sprites.ThrowIfNull(nameof(sprites));

            _sprites = sprites.ToArray();
        }
Exemplo n.º 54
0
        public static String StringJoin <T>([NotNull][ItemCanBeNull] this IEnumerable <T> enumerable, String separator = "")
        {
            enumerable.ThrowIfNull(nameof(enumerable));

            return(String.Join(separator, enumerable));
        }
Exemplo n.º 55
0
 public static IEnumerable <T> Merge <T>(this IEnumerable <IEnumerable <T> > sources)
 {
     sources.ThrowIfNull("sources");
     return(sources.AsParallel().SelectMany(_ => _));
 }
Exemplo n.º 56
0
 public static IEnumerable <T> StartWith <T>(this IEnumerable <T> source, params T[] first)
 {
     source.ThrowIfNull("source");
     return(first.Concat(source));
 }
Exemplo n.º 57
0
 public static IEnumerable <T> Rotate <T>(this IEnumerable <T> source, int offset)
 {
     source.ThrowIfNull("source");
     return(source.Skip(offset).Concat(source.Take(offset)));
 }
Exemplo n.º 58
0
 public ReceiptEngine(ILogger <ReceiptEngine> logger, IEnumerable <ITaxCalculationStrategy> taxCalculationStrategies, IProductRepository productRepository)
     : base(logger)
 {
     _taxCalculationStrategies = taxCalculationStrategies.ThrowIfNull(nameof(taxCalculationStrategies));
     _productRepository        = productRepository.ThrowIfNull(nameof(productRepository));
 }
Exemplo n.º 59
0
        /// <summary>
        /// Prepends a single value to a sequence.
        /// </summary>
        /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam>
        /// <param name="source">The sequence to prepend to.</param>
        /// <param name="value">The value to prepend.</param>
        /// <returns>
        /// Returns a sequence where a value is prepended to it.
        /// </returns>
        /// <remarks>
        /// This operator uses deferred execution and streams its results.
        /// </remarks>
        /// <code>
        /// int[] numbers = { 1, 2, 3 };
        /// IEnumerable&lt;int&gt; result = numbers.Prepend(0);
        /// </code>
        /// The <c>result</c> variable, when iterated over, will yield
        /// 0, 1, 2 and 3, in turn.

        public static IEnumerable <TSource> Prepend <TSource> (this IEnumerable <TSource> source, TSource value)
        {
            source.ThrowIfNull("source");
            return(LinqEnumerable.Concat(LinqEnumerable.Repeat(value, 1), source));
        }
Exemplo n.º 60
0
        public static AttributeSet Create(IEnumerable <KeyValuePair <string, object> > collection)
        {
            collection.ThrowIfNull();

            return(new AttributeSet(collection));
        }