Inheritance: MonoBehaviour
        private void AddGuard()
        {
            FirstName = Trim(FirstName);
            LastName = Trim(LastName);

            Contragent contragent = new Contragent { FirstName = FirstName, LastName = LastName };
            Guard guard = new Guard { Contragent = contragent };

            try
            {
                _mainViewModel.Context.Guards.Add(guard);
                _mainViewModel.Context.SaveChanges();
            }
            catch (Exception e)
            {
                MessageBox.Show(("Не удалось добавить нового мастера"), "Error",
                        MessageBoxButton.OK, MessageBoxImage.Error);

                Logging.WriteToLog("Failed add new repairer" + e.Message);
            }

            _mainViewModel.GuardsViewModel.Update();

            _mainViewModel.GuardsViewModel.AddGuardDialogViewModel = null;
        }
 void Start()
 {
     guard = GetComponent<Guard>();
     butler = GetComponent<Butler>();
     player = GetComponent<SpriteRenderer>();
     position = transform.position;
     AssignParts();
 }
        public void TestPullingGuard()

        {

            Guard pullingGuard = new Guard();

            Assert.AreEqual("I am pulling to block",pullingGuard.Pattern());

        }
示例#4
0
        public Dictionary<Version, SqlFileInfo> FindUnappliedMigrationsSince(Version version, SqlDirInfo dir,
                                                                             Guard guard = null)
        {
            var r = new Dictionary<Version, SqlFileInfo>();

            foreach (DirectoryInfo majorDir in dir.DirectoryInfo.GetDirectories())
            {
            }

            return r;
        }
示例#5
0
        public static IGuard Combine(params IGuard[] others)
        {
            var g = new Guard();

            foreach (var guard in others)
            {
                g.AddOtherInvariants(((Guard)guard).model);
            }

            return g;
        }
示例#6
0
        /// <summary>
        /// Creates the initial guards
        /// </summary>
        public void InitializeGuards()
        {
            Guard doug = new Guard("Doug", Person.Genders.Male, Person.Races.Orc);
            int[] dougCoords = { 0, 0};
            doug.CurrentRoom = dougCoords;
            Guards.Add(doug);

            Guard sandra = new Guard("Sandra", Person.Genders.Female, Person.Races.Elf);
            int[] sandraCoords = { 0, 2 };
            sandra.CurrentRoom = sandraCoords;
            Guards.Add(sandra);
        }
示例#7
0
 public override void Enter()
 {
     base.Enter();
     guard = GetComponent<Guard>();
     hpBar = GameObject.Find("HealthBar").GetComponent<HealthBar>();
     agent = GetComponent<NavMeshAgent>();
     speed += speed / 100 * _waveStats._percentSpeed;
     dammage += dammage / 100 * _waveStats._percentDamage;
     originalSpeed = speed;
     StartCoroutine("charge");
     atackMove = false;
     //print(agent.speed);
 }
示例#8
0
文件: Sword.cs 项目: Antrum/Unity
    public Sword(int _bladeWeaponSet, int _gripWeaponSet, int _guardWeaponSet, int _pommelWeaponSet)
    {
        //		transform.gameObject.AddComponent<Blade> ();
        //		transform.gameObject.AddComponent<Grip> ();
        //		transform.gameObject.AddComponent<Guard> ();
        //		transform.gameObject.AddComponent<Pommel> ();
        //
        //		blade = transform.gameObject.GetComponent<Blade> ();
        //		grip = transform.gameObject.GetComponent<Grip> ();
        //		guard = transform.gameObject.GetComponent<Guard> ();
        //		pommel = transform.gameObject.GetComponent<Pommel> ();

        blade = new Blade (_bladeWeaponSet);
        grip = new Grip (_gripWeaponSet);
        guard = new Guard (_guardWeaponSet);
        pommel = new Pommel (_pommelWeaponSet);
    }
示例#9
0
 public static Employee CreateTrainee(Employee mentor, String name)
 {
     Employee position;
     if (mentor.Mentor != null)
         throw new Exception("Error. Trainee class. Trainee could not be a mentor.");
     if (mentor is Worker)
         position = new Worker(name, 1.5M);
     else if (mentor is Guard)
         position = new Guard(name, 1.5M, 1.5M);
     else if (mentor is Doctor)
         position = new Doctor(name, 1.5M);
     else if (mentor is Psychologist)
         position = new Psychologist(name, 1.5M);
     else
         throw new Exception("Error. Trainee class. Mentor's class is undefined.");
     position.Mentor = mentor;
     return position;
 }
 public ReliableInputSessionChannelOverDuplex(ReliableChannelListenerBase<IInputSessionChannel> listener, IServerReliableChannelBinder binder, FaultHelper faultHelper, UniqueId inputID) : base(listener, binder, faultHelper, inputID)
 {
     this.guard = new Guard(0x7fffffff);
     this.acknowledgementInterval = listener.AcknowledgementInterval;
     this.acknowledgementTimer = new IOThreadTimer(new Action<object>(this.OnAcknowledgementTimeoutElapsed), null, true);
     base.DeliveryStrategy.DequeueCallback = new Action(this.OnDeliveryStrategyItemDequeued);
     if (binder.HasSession)
     {
         try
         {
             base.StartReceiving(false);
         }
         catch (Exception exception)
         {
             if (Fx.IsFatal(exception))
             {
                 throw;
             }
             base.ReliableSession.OnUnknownException(exception);
         }
     }
 }
示例#11
0
        public void InitializeGuards()
        {
            Guard guard;

            //  Andy
            guard = new Guard(
                "Andy",
                "He wears a nice suit.",
                Character.Genders.MALE,
                Character.Races.HUMAN);
            guard.CurrentRoomNumber = 0; // North of building
            guard.Greeting = "Hello there!";
            _guards.Add(guard);

            //  Gordon
            guard = new Guard(
                "Gordon",
                "The standard guard uniform doesn't quite fit him.",
                Character.Genders.MALE,
                Character.Races.ELF);
            guard.CurrentRoomNumber = 2; // South of building
            guard.Greeting = "This is the employee entrance, you'll need an ID to enter.";
            _guards.Add(guard);
        }
示例#12
0
 public ViewModelAppInitializer(IRegisterCallbacks registerCallbacks)
 {
     Guard.NotNull(registerCallbacks, nameof(registerCallbacks));
     this.registerCallbacks = registerCallbacks;
 }
示例#13
0
        protected override void OnValidate()
        {
            Guard.IsDefined(Type);

            Guard.IsNotNullOrWhiteSpace(Name);
            Guard.HasSizeBetweenOrEqualTo(Name, Discord.Limits.ApplicationCommands.Options.MinNameLength, Discord.Limits.ApplicationCommands.Options.MaxNameLength);

            Guard.IsNotNullOrWhiteSpace(Description);
            Guard.HasSizeBetweenOrEqualTo(Description, Discord.Limits.ApplicationCommands.Options.MinDescriptionLength, Discord.Limits.ApplicationCommands.Options.MaxDescriptionLength);

            if (Type is not SlashCommandOptionType.String and not SlashCommandOptionType.Integer and not SlashCommandOptionType.Number)
            {
                OptionalGuard.HasNoValue(Choices, "Choices can only be specified for string, integer, and number options.");

                if (AutoComplete.HasValue)
                {
                    Guard.IsNotEqualTo(true, AutoComplete.Value);
                }
            }

            if (Type is not SlashCommandOptionType.Subcommand and not SlashCommandOptionType.SubcommandGroup)
            {
                OptionalGuard.HasNoValue(Options, "Nested options can only be specified for subcommands and subcommand groups.");
            }

            if (AutoComplete.HasValue && AutoComplete.Value)
            {
                OptionalGuard.HasNoValue(Choices, "Choices cannot be present when auto-complete is enabled.");
            }

            OptionalGuard.CheckValue(Choices, value =>
            {
                Guard.IsNotNull(value);
                Guard.HasSizeLessThanOrEqualTo(value, Discord.Limits.ApplicationCommands.Options.MaxChoiceAmount);

                foreach (var choice in value)
                {
                    Guard.IsNotNull(choice);
                    choice.Validate();
                }
            });

            OptionalGuard.CheckValue(Options, value =>
            {
                Guard.IsNotNull(value);
                Guard.HasSizeLessThanOrEqualTo(value, Discord.Limits.ApplicationCommands.MaxOptionsAmount);

                foreach (var option in value)
                {
                    Guard.IsNotNull(option);
                    option.Validate();
                }
            });

            OptionalGuard.CheckValue(ChannelTypes, value =>
            {
                Guard.IsNotNull(value);

                foreach (var channelType in value)
                {
                    Guard.IsDefined(channelType);
                }
            });
        }
示例#14
0
 public ID2D1DrawingStateBlock1 CreateDrawingStateBlock(DrawingStateDescription1 drawingStateDescription, IDWriteRenderingParams textRenderingParams)
 {
     Guard.NotNull(textRenderingParams, nameof(textRenderingParams));
     return(CreateDrawingStateBlock(drawingStateDescription, textRenderingParams));
 }
 public ConfigurationSection([NotNull] IConfigurationSection root)
 {
     _root = Guard.NotNull(root, nameof(root));
 }
        protected virtual object CreateModelPart(Order part, MessageContext messageContext)
        {
            Guard.NotNull(messageContext, nameof(messageContext));
            Guard.NotNull(part, nameof(part));

            var allow = new HashSet <string>
            {
                nameof(part.Id),
                nameof(part.OrderNumber),
                nameof(part.OrderGuid),
                nameof(part.StoreId),
                nameof(part.OrderStatus),
                nameof(part.PaymentStatus),
                nameof(part.ShippingStatus),
                nameof(part.CustomerTaxDisplayType),
                nameof(part.TaxRatesDictionary),
                nameof(part.VatNumber),
                nameof(part.AffiliateId),
                nameof(part.CustomerIp),
                nameof(part.CardType),
                nameof(part.CardName),
                nameof(part.MaskedCreditCardNumber),
                nameof(part.DirectDebitAccountHolder),
                nameof(part.DirectDebitBankCode),                 // TODO: (mc) Liquid > Bank data (?)
                nameof(part.PurchaseOrderNumber),
                nameof(part.ShippingMethod),
                nameof(part.PaymentMethodSystemName),
                nameof(part.ShippingRateComputationMethodSystemName)
                // TODO: (mc) Liquid > More whitelisting?
            };

            var m = new HybridExpando(part, allow, MemberOptMethod.Allow);
            var d = m as dynamic;

            d.ID      = part.Id;
            d.Billing = CreateModelPart(part.BillingAddress, messageContext);
            if (part.ShippingAddress != null)
            {
                d.Shipping = part.ShippingAddress.IsPostalDataEqual(part.BillingAddress) == true ? null : CreateModelPart(part.ShippingAddress, messageContext);
            }
            d.CustomerEmail   = part.BillingAddress.Email.NullEmpty();
            d.CustomerComment = part.CustomerOrderComment.NullEmpty();
            d.Disclaimer      = GetTopic("Disclaimer", messageContext);
            d.ConditionsOfUse = GetTopic("ConditionsOfUse", messageContext);
            d.Status          = part.OrderStatus.GetLocalizedEnum(_services.Localization, messageContext.Language.Id);
            d.CreatedOn       = ToUserDate(part.CreatedOnUtc, messageContext);
            d.PaidOn          = ToUserDate(part.PaidDateUtc, messageContext);

            // Payment method
            var paymentMethodName = part.PaymentMethodSystemName;
            var paymentMethod     = _services.Resolve <IProviderManager>().GetProvider <IPaymentMethod>(part.PaymentMethodSystemName);

            if (paymentMethod != null)
            {
                paymentMethodName = GetLocalizedValue(messageContext, paymentMethod.Metadata, nameof(paymentMethod.Metadata.FriendlyName), x => x.FriendlyName);
            }
            d.PaymentMethod = paymentMethodName.NullEmpty();

            d.Url = part.Customer != null && !part.Customer.IsGuest()
                                ? BuildActionUrl("Details", "Order", new { id = part.Id, area = "" }, messageContext)
                                : null;

            // Overrides
            m.Properties["OrderNumber"] = part.GetOrderNumber().NullEmpty();
            m.Properties["AcceptThirdPartyEmailHandOver"] = GetBoolResource(part.AcceptThirdPartyEmailHandOver, messageContext);

            // Items, Totals & Co.
            d.Items  = part.OrderItems.Where(x => x.Product != null).Select(x => CreateModelPart(x, messageContext)).ToList();
            d.Totals = CreateOrderTotalsPart(part, messageContext);

            // Checkout Attributes
            if (part.CheckoutAttributeDescription.HasValue())
            {
                d.CheckoutAttributes = HtmlUtils.ConvertPlainTextToTable(HtmlUtils.ConvertHtmlToPlainText(part.CheckoutAttributeDescription)).NullEmpty();
            }

            PublishModelPartCreatedEvent <Order>(part, m);

            return(m);
        }
示例#17
0
        public Room(ref StreamReader m, int xCoord, int yCoord)
        {
            x = xCoord;
            y = yCoord;

            triggerPressed = false;
            roomOrigin = new Vector2((float)xCoord * 100f, (float)yCoord * ((9f / 16f) * 100f));
            backGround = new XNACS1Rectangle(new Vector2(roomOrigin.X + 50f, roomOrigin.Y + 50 * (9f / 16f)), 100f, 100f * (9f / 16f), "dungeonFloor");
            walls = new WallSet(roomOrigin);

            hasStairs = Convert.ToInt32(m.ReadLine());
            numDoors = Convert.ToInt32(m.ReadLine());
            myDoors = new Doors[numDoors];
            numEnemies = Convert.ToInt32(m.ReadLine());
            numKnights = Convert.ToInt32(m.ReadLine());
            roomObjects = new XNACS1PrimitiveSet();
            isAlive = false;
            heroCaught = false;

            if (hasStairs == 1) {
                float stairX = (float)Convert.ToDouble(m.ReadLine());
                float stairY = (float)Convert.ToDouble(m.ReadLine());
                stairs = new Stair(new Vector2(stairX + roomOrigin.X, stairY + roomOrigin.Y));
                roomObjects.AddToSet(stairs);

                float badGuyX = (float)Convert.ToDouble(m.ReadLine());
                float badGuyY = (float)Convert.ToDouble(m.ReadLine());
                badGuy = new Wizard(new Vector2(badGuyX + roomOrigin.X, badGuyY + roomOrigin.Y));

                roomObjects.AddToSet(badGuy);
                hasWon = false;
            }

            activeEnemies = numEnemies;
            myEnemies = new Enemy[numEnemies];
            numGuards = numEnemies - numKnights;
            coord = new Vector2((float)x, (float)y);

            for (int i = 0; i < numGuards; i++) {
                float posX = (float)Convert.ToDouble(m.ReadLine()) + roomOrigin.X;
                string line = m.ReadLine();
                float posY = (float)Convert.ToDouble(line) + roomOrigin.Y;
                myEnemies[i] = new Guard(new Vector2(posX, posY));
                roomObjects.AddToSet(myEnemies[i]);
            }

            for (int i = numGuards; i < numEnemies; i++) {
                float posX = (float)Convert.ToDouble(m.ReadLine()) + roomOrigin.X;
                string line = m.ReadLine();
                float posY = (float)Convert.ToDouble(line) + roomOrigin.Y;
                myEnemies[i] = new Knight(new Vector2(posX, posY));
                roomObjects.AddToSet(myEnemies[i]);
            }

            for (int i = 0; i < numDoors; i++) {
                //takes in the origin of the room and the door type
                myDoors[i] = new Doors(roomOrigin, coord, m.ReadLine());
                roomObjects.AddToSet(myDoors[i]);
            }

            roomObjects.RemoveAllFromAutoDrawSet();

            wand = new Wand();
        }
示例#18
0
        public bool insertGuard(double x1, double y1, double x2, double y2)
        {
            if (Guards == null) { Guards = new SortableBindingList<Guard>(); }

            Guard guard = new Guard(this);
            if (guard.setRange(x1, y1, x2, y2)) {
                guard.Id = "g-" + Guards.Count.ToString();
                Guards.Add(guard);
                return true;
            }
            return false;
        }
示例#19
0
        public RegistrationService(IRepository <Registration> registrationRepository)
        {
            Guard.NotNull(registrationRepository, nameof(registrationRepository));

            _registrationRepository = registrationRepository;
        }
        public DefaultUserResolver(IServiceProvider serviceProvider)
        {
            Guard.NotNull(serviceProvider, nameof(serviceProvider));

            this.serviceProvider = serviceProvider;
        }
示例#21
0
        private PolicyDefinition AddElement <T>(string name, UpdateElements update)
        {
            Guard.ArgumentNotNull(name, "name");

            return(update(name));
        }
示例#22
0
        /// <summary>
        /// Orders the collection using the specified <see cref="IComparer{T}"/>.
        /// </summary>
        /// <param name="collection">The collection reference.</param>
        /// <param name="comparer">The <see cref="IComparer{T}"/> to use. If left null, the default <see cref="IComparer{T}"/> is used.</param>
        /// <exception cref="ArgumentNullException"><paramref name="collection"/> is <see langword="null"/></exception>
        public static IEnumerable <T?> OrderBy <T>(this IEnumerable <T?> collection, IComparer <T?>?comparer)
        {
            Guard.IsNotNull(collection, nameof(collection));

            return(collection.OrderBy(FuncProvider <T?> .ReturnSelf, new ComparerBridge <T?>(comparer)));
        }
示例#23
0
 public void NonAssignableTypesThrow()
 {
     Guard.TypeIsAssignableFromType(typeof(object), typeof(string), "argument");
 }
示例#24
0
 public void EnumValueIsDefinedThrowIfValueIsUndefined()
 {
     Guard.EnumValueIsDefined(typeof(TestEnum), 2, "argument");
 }
示例#25
0
 public void StringNotNullOrEmptyDoesNotThrowWithValidString()
 {
     Guard.ArgumentNotNullOrEmptyString("Foo", "Foo");
 }
示例#26
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            grid = new Grid(13, 11);
            //grid = new Grid(47, 54);

            intruder = new Intruder[NO_OF_INTRUDERS];
            shotSystem = new ShotSystem();
            for (int n = 0; n < NO_OF_INTRUDERS; n++)
                intruder[n] = new Intruder();
            guard = new Guard();
            guard.Init(ref grid);

            graphics.PreferredBackBufferHeight = 768;
            graphics.PreferredBackBufferWidth = 1366;
            graphics.PreferMultiSampling = true;
            graphics.IsFullScreen = false;
            graphics.ApplyChanges();

            Camera.centreOfScreen = new Vector2(1366 * 0.5f, 768 * 0.5f);
            Camera.pos = Camera.centreOfScreen;

            keyboard = Keyboard.GetState();

            base.Initialize();
        }
示例#27
0
        public static IEnumerable <SchemaEvent> Synchronize(this Schema source, Schema?target, Func <long> idGenerator,
                                                            SchemaSynchronizationOptions?options = null)
        {
            Guard.NotNull(source, nameof(source));
            Guard.NotNull(idGenerator, nameof(idGenerator));

            if (target == null)
            {
                yield return(new SchemaDeleted());
            }
            else
            {
                options ??= new SchemaSynchronizationOptions();

                if (!source.Properties.Equals(target.Properties))
                {
                    yield return(new SchemaUpdated {
                        Properties = target.Properties
                    });
                }

                if (!source.Category.StringEquals(target.Category))
                {
                    yield return(new SchemaCategoryChanged {
                        Name = target.Category
                    });
                }

                if (!source.Scripts.Equals(target.Scripts))
                {
                    yield return(new SchemaScriptsConfigured {
                        Scripts = target.Scripts
                    });
                }

                if (!source.PreviewUrls.EqualsDictionary(target.PreviewUrls))
                {
                    yield return(new SchemaPreviewUrlsConfigured {
                        PreviewUrls = target.PreviewUrls
                    });
                }

                if (source.IsPublished != target.IsPublished)
                {
                    yield return(target.IsPublished ?
                                 new SchemaPublished() :
                                 new SchemaUnpublished());
                }

                var events = SyncFields(source.FieldCollection, target.FieldCollection, idGenerator, CanUpdateRoot, options);

                foreach (var @event in events)
                {
                    yield return(@event);
                }

                if (!source.FieldsInLists.Equals(target.FieldsInLists))
                {
                    yield return(new SchemaUIFieldsConfigured {
                        FieldsInLists = target.FieldsInLists
                    });
                }

                if (!source.FieldsInReferences.Equals(target.FieldsInReferences))
                {
                    yield return(new SchemaUIFieldsConfigured {
                        FieldsInReferences = target.FieldsInReferences
                    });
                }

                if (!source.FieldRules.Equals(target.FieldRules))
                {
                    yield return(new SchemaFieldRulesConfigured {
                        FieldRules = target.FieldRules
                    });
                }
            }
        }
示例#28
0
 public void SetUp()
 {
     _strategy = new Flat();
     _version = new NeosIT.DB_Migrator.DBMigration.Version { Major = "20120101", Minor = "001", };
     _guard = new Guard();
 }
示例#29
0
		public void InitializeUiConfig(UiConfig uiConfig)
		{
			UiConfig = Guard.NotNull(nameof(uiConfig), uiConfig);
		}
示例#30
0
 public bool insertGuard()
 {
     Guard guard = new Guard(this);
     guard.Id = "g-" + Guards.Count.ToString();
     Guards.Add(guard);
     return true;
 }
示例#31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BasketController" /> class.
 /// </summary>
 /// <param name="sessionManager">The session manager.</param>
 public BasketController(ISessionManager sessionManager)
 {
     Guard.ArgumentNotNull(sessionManager, "sessionManager");
     this.sessionManager = sessionManager;
 }
示例#32
0
        public static Guard New()
        {
            _guard = new Guard();

            return _guard;
        }
示例#33
0
        public static void Register(IComponentRegistry registry, IServiceBusConfiguration configuration)
        {
            Guard.AgainstNull(registry, nameof(registry));
            Guard.AgainstNull(configuration, nameof(configuration));

            registry.RegistryBootstrap();

            registry.AttemptRegisterInstance(configuration);

            registry.AttemptRegister <IServiceBusEvents, ServiceBusEvents>();
            registry.AttemptRegister <ISerializer, DefaultSerializer>();
            registry.AttemptRegister <IServiceBusPolicy, DefaultServiceBusPolicy>();
            registry.AttemptRegister <IMessageRouteProvider, DefaultMessageRouteProvider>();
            registry.AttemptRegister <IIdentityProvider, DefaultIdentityProvider>();
            registry.AttemptRegister <IMessageHandlerInvoker, DefaultMessageHandlerInvoker>();
            registry.AttemptRegister <IMessageHandlingAssessor, DefaultMessageHandlingAssessor>();
            registry.AttemptRegister <IUriResolver, DefaultUriResolver>();
            registry.AttemptRegister <IQueueManager, QueueManager>();
            registry.AttemptRegister <IWorkerAvailabilityManager, WorkerAvailabilityManager>();
            registry.AttemptRegister <ISubscriptionManager, NullSubscriptionManager>();
            registry.AttemptRegister <IIdempotenceService, NullIdempotenceService>();
            registry.AttemptRegister <ITransactionScopeObserver, TransactionScopeObserver>();
            registry.AttemptRegister <ICancellationTokenSource, DefaultCancellationTokenSource>();

            if (!registry.IsRegistered <ITransactionScopeFactory>())
            {
                var transactionScopeConfiguration = configuration.TransactionScope ??
                                                    new TransactionScopeConfiguration();

                registry.AttemptRegisterInstance <ITransactionScopeFactory>(
                    new DefaultTransactionScopeFactory(transactionScopeConfiguration.Enabled,
                                                       transactionScopeConfiguration.IsolationLevel,
                                                       TimeSpan.FromSeconds(transactionScopeConfiguration.TimeoutSeconds)));
            }

            registry.AttemptRegister <IPipelineFactory, DefaultPipelineFactory>();
            registry.AttemptRegister <ITransportMessageFactory, DefaultTransportMessageFactory>();

            var reflectionService = new ReflectionService();

            foreach (var type in reflectionService.GetTypesAssignableTo <IPipeline>(typeof(ServiceBus).Assembly))
            {
                if (type.IsInterface || type.IsAbstract || registry.IsRegistered(type))
                {
                    continue;
                }

                registry.Register(type, type, Lifestyle.Transient);
            }

            foreach (var type in reflectionService.GetTypesAssignableTo <IPipelineObserver>(typeof(ServiceBus).Assembly))
            {
                if (type.IsInterface || type.IsAbstract)
                {
                    continue;
                }

                var interfaceType = type.InterfaceMatching($"I{type.Name}");

                if (interfaceType != null)
                {
                    if (registry.IsRegistered(type))
                    {
                        continue;
                    }

                    registry.Register(interfaceType, type, Lifestyle.Singleton);
                }
                else
                {
                    throw new EsbConfigurationException(string.Format(Resources.ObserverInterfaceMissingException, type.Name));
                }
            }

            if (configuration.RegisterHandlers)
            {
                foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
                {
                    foreach (var type in reflectionService.GetTypesAssignableTo(MessageHandlerType, assembly))
                    {
                        foreach (var @interface in type.GetInterfaces())
                        {
                            if ([email protected](MessageHandlerType))
                            {
                                continue;
                            }

                            var genericType = MessageHandlerType.MakeGenericType(@interface.GetGenericArguments()[0]);

                            if (!registry.IsRegistered(genericType))
                            {
                                registry.Register(genericType, type, Lifestyle.Transient);
                            }
                        }
                    }
                }
            }

            var queueFactoryType = typeof(IQueueFactory);
            var queueFactoryImplementationTypes = new HashSet <Type>();

            void AddQueueFactoryImplementationType(Type type)
            {
                queueFactoryImplementationTypes.Add(type);
            }

            if (configuration.ScanForQueueFactories)
            {
                foreach (var type in new ReflectionService().GetTypesAssignableTo <IQueueFactory>())
                {
                    AddQueueFactoryImplementationType(type);
                }
            }

            foreach (var type in configuration.QueueFactoryTypes)
            {
                AddQueueFactoryImplementationType(type);
            }

            registry.RegisterCollection(queueFactoryType, queueFactoryImplementationTypes, Lifestyle.Singleton);

            registry.AttemptRegister <IServiceBus, ServiceBus>();
        }
        protected virtual object CreateOrderTotalsPart(Order order, MessageContext messageContext)
        {
            Guard.NotNull(messageContext, nameof(messageContext));
            Guard.NotNull(order, nameof(order));

            var language        = messageContext.Language;
            var currencyService = _services.Resolve <ICurrencyService>();
            var paymentService  = _services.Resolve <IPaymentService>();
            var priceFormatter  = _services.Resolve <IPriceFormatter>();
            var taxSettings     = _services.Settings.LoadSetting <TaxSettings>(messageContext.Store.Id);

            var   taxRates    = new SortedDictionary <decimal, decimal>();
            Money cusTaxTotal = null;
            Money cusDiscount = null;
            Money cusRounding = null;
            Money cusTotal    = null;

            var subTotals = GetSubTotals(order, messageContext);

            // Shipping
            bool dislayShipping = order.ShippingStatus != ShippingStatus.ShippingNotRequired;

            // Payment method fee
            bool displayPaymentMethodFee = true;

            if (order.PaymentMethodAdditionalFeeExclTax == decimal.Zero)
            {
                displayPaymentMethodFee = false;
            }

            // Tax
            bool displayTax      = true;
            bool displayTaxRates = true;

            if (taxSettings.HideTaxInOrderSummary && order.CustomerTaxDisplayType == TaxDisplayType.IncludingTax)
            {
                displayTax      = false;
                displayTaxRates = false;
            }
            else
            {
                if (order.OrderTax == 0 && taxSettings.HideZeroTax)
                {
                    displayTax      = false;
                    displayTaxRates = false;
                }
                else
                {
                    taxRates = new SortedDictionary <decimal, decimal>();
                    foreach (var tr in order.TaxRatesDictionary)
                    {
                        taxRates.Add(tr.Key, currencyService.ConvertCurrency(tr.Value, order.CurrencyRate));
                    }

                    displayTaxRates = taxSettings.DisplayTaxRates && taxRates.Count > 0;
                    displayTax      = !displayTaxRates;

                    cusTaxTotal = FormatPrice(order.OrderTax, order, messageContext);
                }
            }

            // Discount
            bool dislayDiscount = false;

            if (order.OrderDiscount > decimal.Zero)
            {
                cusDiscount    = FormatPrice(-order.OrderDiscount, order, messageContext);
                dislayDiscount = true;
            }

            // Total
            var roundingAmount = decimal.Zero;
            var orderTotal     = order.GetOrderTotalInCustomerCurrency(currencyService, paymentService, out roundingAmount);

            cusTotal = FormatPrice(orderTotal, order.CustomerCurrencyCode, messageContext);

            // Rounding
            if (roundingAmount != decimal.Zero)
            {
                cusRounding = FormatPrice(roundingAmount, order.CustomerCurrencyCode, messageContext);
            }

            // Model
            dynamic m = new ExpandoObject();

            m.SubTotal         = subTotals.SubTotal;
            m.SubTotalDiscount = subTotals.DisplaySubTotalDiscount ? subTotals.SubTotalDiscount : null;
            m.Shipping         = dislayShipping ? subTotals.ShippingTotal : null;
            m.Payment          = displayPaymentMethodFee ? subTotals.PaymentFee : null;
            m.Tax          = displayTax ? cusTaxTotal : null;
            m.Discount     = dislayDiscount ? cusDiscount : null;
            m.RoundingDiff = cusRounding;
            m.Total        = cusTotal;
            m.IsGross      = order.CustomerTaxDisplayType == TaxDisplayType.IncludingTax;

            // TaxRates
            m.TaxRates = !displayTaxRates ? (object[])null : taxRates.Select(x =>
            {
                return(new
                {
                    Rate = T("Order.TaxRateLine", language.Id, priceFormatter.FormatTaxRate(x.Key)).Text,
                    Value = FormatPrice(x.Value, order, messageContext)
                });
            }).ToArray();


            // Gift Cards
            m.GiftCardUsage = order.GiftCardUsageHistory.Count == 0 ? (object[])null : order.GiftCardUsageHistory.Select(x =>
            {
                return(new
                {
                    GiftCard = T("Order.GiftCardInfo", language.Id, x.GiftCard.GiftCardCouponCode).Text,
                    UsedAmount = FormatPrice(-x.UsedValue, order, messageContext),
                    RemainingAmount = FormatPrice(x.GiftCard.GetGiftCardRemainingAmount(), order, messageContext)
                });
            }).ToArray();

            // Reward Points
            m.RedeemedRewardPoints = order.RedeemedRewardPointsEntry == null ? null : new
            {
                Title  = T("Order.RewardPoints", language.Id, -order.RedeemedRewardPointsEntry.Points).Text,
                Amount = FormatPrice(-order.RedeemedRewardPointsEntry.UsedAmount, order, messageContext)
            };

            return(m);
        }
 /// <summary>
 /// Interceptor to use.
 /// </summary>
 /// <param name="context">Context for current build operation.</param>
 public IInstanceInterceptor GetInterceptor(IBuilderContext context)
 {
     Guard.ArgumentNotNull(context, "context");
     return (IInstanceInterceptor) context.NewBuildUp(buildKey);
 }
        protected virtual object CreateModelPart(OrderItem part, MessageContext messageContext)
        {
            Guard.NotNull(messageContext, nameof(messageContext));
            Guard.NotNull(part, nameof(part));

            var productAttributeParser = _services.Resolve <IProductAttributeParser>();
            var downloadService        = _services.Resolve <IDownloadService>();
            var deliveryTimeService    = _services.Resolve <IDeliveryTimeService>();
            var order   = part.Order;
            var isNet   = order.CustomerTaxDisplayType == TaxDisplayType.ExcludingTax;
            var product = part.Product;

            product.MergeWithCombination(part.AttributesXml, productAttributeParser);

            // Bundle items.
            object bundleItems = null;

            if (product.ProductType == ProductType.BundledProduct && part.BundleData.HasValue())
            {
                var bundleData = part.GetBundleData();
                if (bundleData.Any())
                {
                    var productService = _services.Resolve <IProductService>();
                    var products       = productService.GetProductsByIds(bundleData.Select(x => x.ProductId).ToArray());
                    var productsDic    = products.ToDictionarySafe(x => x.Id, x => x);

                    bundleItems = bundleData
                                  .OrderBy(x => x.DisplayOrder)
                                  .Select(x =>
                    {
                        productsDic.TryGetValue(x.ProductId, out Product bundleItemProduct);
                        return(CreateModelPart(x, part, bundleItemProduct, messageContext));
                    })
                                  .ToList();
                }
            }

            var m = new Dictionary <string, object>
            {
                { "DownloadUrl", !downloadService.IsDownloadAllowed(part) ? null : BuildActionUrl("GetDownload", "Download", new { id = part.OrderItemGuid, area = "" }, messageContext) },
                { "AttributeDescription", part.AttributeDescription.NullEmpty() },
                { "Weight", part.ItemWeight },
                { "TaxRate", part.TaxRate },
                { "Qty", part.Quantity },
                { "UnitPrice", FormatPrice(isNet ? part.UnitPriceExclTax : part.UnitPriceInclTax, part.Order, messageContext) },
                { "LineTotal", FormatPrice(isNet ? part.PriceExclTax : part.PriceInclTax, part.Order, messageContext) },
                { "Product", CreateModelPart(product, messageContext, part.AttributesXml) },
                { "BundleItems", bundleItems },
                { "IsGross", !isNet },
                { "DisplayDeliveryTime", part.DisplayDeliveryTime },
            };

            if (part.DeliveryTimeId.HasValue)
            {
                if (deliveryTimeService.GetDeliveryTimeById(part.DeliveryTimeId ?? 0) is DeliveryTime dt)
                {
                    m["DeliveryTime"] = new Dictionary <string, object>
                    {
                        { "Color", dt.ColorHexValue },
                        { "Name", dt.GetLocalized(x => x.Name, messageContext.Language).Value },
                    };
                }
            }

            PublishModelPartCreatedEvent <OrderItem>(part, m);

            return(m);
        }
示例#37
0
 internal static bool IsAssignableFromNull(Type type)
 {
     Guard.ArgumentNotNull(type, nameof(type));
     return(!type.GetTypeInfo().IsValueType || IsNullable(type));
 }
	    public WorkerAvailableHandler(IWorkerAvailabilityManager workerAvailabilityManager)
	    {
            Guard.AgainstNull(workerAvailabilityManager, "workerAvailabilityManager");

	        _workerAvailabilityManager = workerAvailabilityManager;
	    }
示例#39
0
        private void updateUnitInput()
        {
            /* Selecting Units */
            if (input.wasKeyJustPressed(GameKeys.UNIT_SELECT))
            {
                selectTimer = 0;
                startClickX = input.getMouseX();
                startClickY = input.getMouseY();
                lineTool.setPointsList(new List<Vector3>());
            }
            else if (input.wasKeyJustReleased(GameKeys.UNIT_SELECT))
            {
                currClickX = input.getMouseX();
                currClickY = input.getMouseY();
                // select a single unit
                if ((startClickX == currClickX && startClickY == currClickY) || selectTimer < 6)
                {
                    Vector3 mousePoint = terrain.projectToTerrain(startClickX, startClickY);
                    if (mousePoint != Terrain.BAD_POSITION)
                    {
                        float minDist = 2.5f;
                        MovableEntity selected = null;
                        foreach (MovableEntity entity in entities)
                        {
                            entity.setSelected(false);
                            if (!entity.isDead())
                            {
                                Vector3 dist = mousePoint - entity.getPosition();
                                if (dist.Length() < minDist)
                                {
                                    minDist = dist.Length();
                                    selected = entity;
                                }
                            }
                        }
                        if (selected != null) selected.setSelected(true);
                    }
                }
                //select a group of units
                else
                {
                    int topX = Math.Min(startClickX, currClickX);
                    int topY = Math.Min(startClickY, currClickY);
                    int bottomX = Math.Max(startClickX, currClickX);
                    int bottomY = Math.Max(startClickY, currClickY);
                    Rectangle bounds = new Rectangle(topX, topY, bottomX - topX, bottomY - topY);
                    foreach (MovableEntity entity in entities)
                    {
                        entity.setSelected(false);
                        if (!entity.isDead())
                        {
                            Vector3 entityPos = terrain.projectToScreen(entity.getPosition());
                            if (entityPos.Z < 1 && bounds.Contains(new Point((int)entityPos.X, (int)entityPos.Y)))
                                entity.setSelected(true);
                        }
                    }
                }
            }
            if (input.isKeyPressed(GameKeys.UNIT_SELECT))
            {
                selectTimer++;
                currClickX = input.getMouseX();
                currClickY = input.getMouseY();
                if (selectTimer >= 6)
                {
                    int screenX = getGraphics().Viewport.Width / 2;
                    int screenY = getGraphics().Viewport.Height / 2;
                    List<Vector3> boundingBox = new List<Vector3>();
                    boundingBox.Add(new Vector3((startClickX - screenX) / (float)screenX, -(startClickY - screenY) / (float)screenY, 0));
                    boundingBox.Add(new Vector3((currClickX - screenX) / (float)screenX, -(startClickY - screenY) / (float)screenY, 0));
                    boundingBox.Add(new Vector3((currClickX - screenX) / (float)screenX, -(currClickY - screenY) / (float)screenY, 0));
                    boundingBox.Add(new Vector3((startClickX - screenX) / (float)screenX, -(currClickY - screenY) / (float)screenY, 0));
                    boundingBox.Add(new Vector3((startClickX - screenX) / (float)screenX, -(startClickY - screenY) / (float)screenY, 0));
                    lineTool.setPointsList(boundingBox);
                }
            }

            /* Commanding Units */
            if (input.wasKeyJustPressed(GameKeys.UNIT_COMMAND))
            {
                Vector3 mousePoint = terrain.projectToTerrain(input.getMouseX(), input.getMouseY());
                if (mousePoint != Terrain.BAD_POSITION)
                {
                    foreach (MovableEntity entity in entities)
                    {
                        if (entity.IsSelected)
                        {
                            bool pathFound;
                            Path p = aStar.computePath(entity.getPosition().X, entity.getPosition().Y, mousePoint.X, mousePoint.Y, out pathFound);
                            if (pathFound)
                                entity.setPath(p);
                        }
                    }
                }
            }

            /* Spawning Units */
            if (input.wasKeyJustReleased(GameKeys.UNIT_SPAWN_GUARD))
            {
                Vector3 mousePoint = terrain.projectToTerrain(input.getMouseX(), input.getMouseY());
                if (mousePoint != Terrain.BAD_POSITION)
                {
                    List<Vector3> dummyPath = new List<Vector3>();
                    dummyPath.Add(mousePoint);
                    MovableEntity newEntity = new Guard(this, levelInfo, modelLoader, new Path(dummyPath), 0, projectileManager);
                    entities.Add(newEntity);
                    soundManager.playSound(SoundHandle.Truck, newEntity);
                }
            }
            else if (input.wasKeyJustReleased(GameKeys.UNIT_SPAWN_SCOUT))
            {
                Vector3 mousePoint = terrain.projectToTerrain(input.getMouseX(), input.getMouseY());
                if (mousePoint != Terrain.BAD_POSITION)
                {
                    List<Vector3> dummyPath = new List<Vector3>();
                    dummyPath.Add(mousePoint);
                    MovableEntity newEntity = new Scout(this, levelInfo, modelLoader, new Path(dummyPath), 0);
                    entities.Add(newEntity);
                    soundManager.playSound(SoundHandle.Truck, newEntity);
                }
            }
            else if (input.wasKeyJustReleased(GameKeys.UNIT_SPAWN_TANKER))
            {
                Vector3 mousePoint = terrain.projectToTerrain(input.getMouseX(), input.getMouseY());
                if (mousePoint != Terrain.BAD_POSITION)
                {
                    List<Vector3> dummyPath = new List<Vector3>();
                    dummyPath.Add(mousePoint);
                    MovableEntity newEntity = new Tanker(this, levelInfo, modelLoader, new Path(dummyPath), 0);
                    entities.Add(newEntity);
                    soundManager.playSound(SoundHandle.Truck, newEntity);
                }
            }

            /* Deleting Units */
            if (input.wasKeyJustReleased(GameKeys.UNIT_DELETE))
            {
                Vector3 mousePoint = terrain.projectToTerrain(input.getMouseX(), input.getMouseY());
                if (mousePoint != Terrain.BAD_POSITION)
                {
                    float minDist = 5.0f;
                    MovableEntity deleted = null;
                    foreach (MovableEntity entity in entities)
                    {
                        Vector3 dist = mousePoint - entity.getPosition();
                        if (dist.Length() < minDist)
                        {
                            minDist = dist.Length();
                            deleted = entity;
                        }
                    }
                    if (deleted != null) entities.Remove(deleted);
                }
            }
        }
示例#40
0
        public ID2D1StrokeStyle1 CreateStrokeStyle(StrokeStyleProperties1 properties, float[] dashes)
        {
            Guard.NotNullOrEmpty(dashes, nameof(dashes));

            return(CreateStrokeStyle(ref properties, dashes, dashes.Length));
        }
示例#41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PixelateProcessor{TColor,TPacked}"/> class.
 /// </summary>
 /// <param name="size">The size of the pixels. Must be greater than 0.</param>
 /// <exception cref="System.ArgumentException">
 /// <paramref name="size"/> is less than 0 or equal to 0.
 /// </exception>
 public PixelateProcessor(int size)
 {
     Guard.MustBeGreaterThan(size, 0, nameof(size));
     this.Value = size;
 }
示例#42
0
        public AllowedValuesValidator(IEnumerable <TValue> allowedValues)
        {
            Guard.NotNull(allowedValues, nameof(allowedValues));

            this.allowedValues = allowedValues;
        }
示例#43
0
 /// <summary>
 /// When overridden in a derived class, sets the <see cref="T:System.Runtime.Serialization.SerializationInfo" /> with information about the exception.
 /// </summary>
 /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
 /// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.</param>
 /// <exception cref="System.ArgumentNullException">info</exception>
 /// <PermissionSet>
 ///   <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="*AllFiles*" PathDiscovery="*AllFiles*" />
 ///   <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="SerializationFormatter" />
 /// </PermissionSet>
 public override void GetObjectData(SerializationInfo info, StreamingContext context)
 {
     Guard.NotNull(() => info, info);
     info.AddValue("CompileCode", CompileCode);
     base.GetObjectData(info, context);
 }
示例#44
0
 public bool CheckGuardIsOnSight(Guard p_Guard)
 {
     float dist = (p_Guard.transform.position - transform.position).magnitude;
     //Debug.Log("Dist ["+ dist + "] MaxDist ["+ m_Dist + "]");
     if (dist < p_Guard.m_Dist)
     {
         Vector3 project = new Vector3(p_Guard.transform.position.x, transform.position.y, p_Guard.transform.position.z);
         Vector3 dirToGuard = (p_Guard.transform.position - transform.position).normalized;
         Vector3 dirToGuardProj = (project - transform.position).normalized;
         float angle = Vector3.Angle(transform.forward, dirToGuardProj);
         //Debug.Log(angle);
         if (angle < p_Guard.m_Angle)
         {
             RaycastHit hit;
             //Debug.DrawRay(transform.position + Vector3.up, dirToGuard * p_Guard.m_Dist, Color.red);
             if (Physics.Raycast(transform.position, dirToGuard, out hit, p_Guard.m_Dist))
                 return (hit.transform.tag == "Guard") ? true : false;
         }
     }
     return false;
 }
示例#45
0
 public AbsolutePathInTocPageFileTransformer(PdfOptions pdfOptions)
 {
     Guard.ArgumentNotNull(pdfOptions, nameof(pdfOptions));
     _pdfOptions = pdfOptions;
 }
示例#46
0
 public void SetUp()
 {
     _strategy = new Flat();
     _version = new Version {Major = "20120307", Minor = "001",};
     _guard = new Guard();
 }
示例#47
0
    void spawnCheck()
    {
        //print(enemiesToSpawn);
        if (enemiesToSpawn > 0 && Time.time > nextSpawnTime)//checks if there are enemies left to spawn this wave and if it is time to spawn a enemy, if it executes it ajusts the amount of enemies that need to spawn, resets the timer and spawns a enemy
        {
            //print("kijk");
            enemiesToSpawn--;
            nextSpawnTime = Time.time + currentWave.spawnTime;

            //print("ello" + enemy);
            if (_112233)//functie die er voor zorgt dat als 112233 true is dat de eerste eerst worden gespawned dan de 2e en dan de 3e
            {
                if (currentWave.enemyCount1 != 0)
                {
                    currentEnemy = enemies[0];
                    enemy = currentEnemy.enemy;
                    currentWave.enemyCount1--;
                }
                else if (currentWave.enemyCount2 != 0)
                {
                    currentEnemy = enemies[1];
                    enemy = currentEnemy.enemy;
                    currentWave.enemyCount2--;
                }
                else if (currentWave.enemyCount3 != 0)
                {
                    currentEnemy = enemies[2];
                    enemy = currentEnemy.enemy;
                    currentWave.enemyCount3--;
                }
                else if (currentWave.enemyCount4 != 0)
                {
                    currentEnemy = enemies[3];
                    enemy = currentEnemy.enemy;
                    currentWave.enemyCount4--;
                }
                else if (currentWave.enemyCount5 != 0)
                {
                    currentEnemy = enemies[4];
                    enemy = currentEnemy.enemy;
                    currentWave.enemyCount5--;
                }
            }
            if (spawnpointDivider >= spawnpoints.Length)
            {
                spawnpointDivider = 0;
            }
            Guard spawnedEnemy = Instantiate(enemy, spawnpoints[spawnpointDivider].position, Quaternion.identity) as Guard;
            spawnpointDivider++;
            spawnedEnemy.OnDeath += OnEnemyDeath;//when ondeath is called, onenemydeath wil be called to
        }
        if (waveDone == true)
        {
            maxTimeCounter -= Time.deltaTime;

            if (maxTimeCounter <= 0)
            {
                NextWave();

                print("test me biatch");
                wavesCounter++;
                waveDone = false;
            }
        }
    }
示例#48
0
 public TriggerGuard(ProductTrigger t, Guard g)
 {
     Trigger = t;
     Guard = g;
 }
 public override void FromBytes(byte[] bytes) => Bytes = Guard.NotNullOrEmpty(nameof(bytes), bytes);
示例#50
0
文件: Game.cs 项目: Simsso/Crusades
        // spawns unit on given coord
        public Unit SpawnUnit(UnitType Type, Coord Position)
        {
            ChangedSinceLoading = true;

            Unit ToSpawn = null; ;
            switch (Type)
            {
                case UnitType.Guard:
                    ToSpawn = new Guard(Position, Turn);
                    break;
                case UnitType.PikeMan:
                    ToSpawn = new PikeMan(Position, Turn);
                    break;
                case UnitType.Swordsman:
                    ToSpawn = new Swordsman(Position, Turn);
                    break;
                case UnitType.Archers:
                    ToSpawn = new Archers(Position, Turn);
                    break;
                case UnitType.LightCavalry:
                    ToSpawn = new LightCavalry(Position, Turn);
                    break;
                case UnitType.BowCavalry:
                    ToSpawn = new BowCavalry(Position, Turn);
                    break;
                case UnitType.HeavyCavalry:
                    ToSpawn = new HeavyCavalry(Position, Turn);
                    break;
                case UnitType.Catapult:
                    ToSpawn = new Catapult(Position, Turn);
                    break;
                case UnitType.Ballista:
                    ToSpawn = new Ballista(Position, Turn);
                    break;
                case UnitType.Trebuchet:
                    ToSpawn = new Trebuchet(Position, Turn);
                    break;
                case UnitType.SiegeTower:
                    ToSpawn = new SiegeTower(Position, Turn);
                    break;
                case UnitType.Battleship:
                    ToSpawn = new Battleship(Position, Turn);
                    break;
                case UnitType.Griffon:
                    ToSpawn = new Griffon(Position, Turn);
                    break;
                default:
                    ToSpawn = null;
                    break;
            }

            if (ToSpawn != null)
            {
                Units.Add(ToSpawn); // add unit to units list
                return ToSpawn;
            }
            return null;
        }
示例#51
0
        public ResourcesLocalizer(ResourceManager resourceManager)
        {
            Guard.NotNull(resourceManager, nameof(resourceManager));

            this.resourceManager = resourceManager;
        }
示例#52
0
        public UsersController(IAuthorizationHelper authorizationHelper)
        {
            Guard.ArgumentNotNull(authorizationHelper, nameof(authorizationHelper));

            _authorizationHelper = authorizationHelper;
        }
示例#53
0
 public GuardViewModel(Guard guard)
     : base(guard.Contragent)
 {
 }
示例#54
0
文件: FlashCone.cs 项目: theKyuu/GLhf
 public FlashCone(Guard a_parent, Vector2 a_offset, string a_sprite, Boolean a_facingRight, float a_layer)
     : base(new CartesianCoordinate(a_offset, a_parent.getPosition()), a_sprite, a_layer)
 {
     setFacingRight(a_facingRight);
     loadContent();
 }
示例#55
0
        public void Transform(IEnumerable <string> htmlFilePaths)
        {
            Guard.ArgumentNotNull(htmlFilePaths, nameof(htmlFilePaths));
            Parallel.ForEach(
                htmlFilePaths,
                htmlFilePath =>
            {
                if (!File.Exists(htmlFilePath))
                {
                    Logger.LogVerbose($"Can not find toc page file: {htmlFilePath}.", htmlFilePath);
                    return;
                }

                try
                {
                    var doc = new HtmlDocument();
                    doc.Load(htmlFilePath);
                    var tags = doc.DocumentNode.SelectNodes("//a[@href]");
                    if (tags?.Count > 0)
                    {
                        bool isTransformed = false;
                        foreach (var tag in tags)
                        {
                            var src = tag.Attributes["href"].Value;
                            if (Uri.TryCreate(src, UriKind.Relative, out Uri uri))
                            {
                                try
                                {
                                    if (Path.IsPathRooted(src))
                                    {
                                        if (string.IsNullOrEmpty(_pdfOptions.Host))
                                        {
                                            Logger.LogVerbose($"No host passed, so just keep the url as origin: {src}.", htmlFilePath);
                                            continue;
                                        }
                                        if (Uri.TryCreate(_pdfOptions.Host, UriKind.Absolute, out Uri host))
                                        {
                                            tag.Attributes["href"].Value = new Uri(host, uri.OriginalString).ToString();
                                            isTransformed = true;
                                        }
                                        else
                                        {
                                            Logger.LogVerbose($"The host format:{_pdfOptions.Host} is invalid, so just keep the url as origin: {src}.", htmlFilePath);
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Logger.LogWarning(ex.Message, htmlFilePath);
                                }
                            }
                        }
                        if (isTransformed)
                        {
                            doc.Save(htmlFilePath);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogWarning($"Transfer absolute path in toc page file error, details: {ex.Message}", htmlFilePath);
                }
            });
        }
示例#56
0
        /// <summary>
        /// Replaces all variables not found in a guard with one.
        /// </summary>
        /// <param name="gate"></param>
        /// <param name="monitor"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        private IGate ReplaceNonGuardVariables(IGate gate, Guard monitor)
        {
            // get variables referenced in the condition
            var variables = monitor.PreCondition
                .SelectAll(e => e is IVariableCondition)
                .OfType<IVariableCondition>()
                .Select(u => u.Variable)
                .Distinct();

            var vset = new HashSet<Variable>(variables);

            // TraceDependencies("monitor variables: {0}", variables.ToSeparatorList());

            IGate r = gate
                .Replace(g =>
                {
                    if (g is IVariableCondition)
                    {
                        var vc = (IVariableCondition)g;
                        if (!vset.Contains(vc.Variable))
                        {
                            g = Gate.Constant(true);
                        }
                    }

                    return g;
                })
                .Simplify();

            return r;
        }
示例#57
0
        public Guard AddGuard(ICondition c, GuardType gtype = GuardType.ENTER, string name = null)
        {
            if (string.IsNullOrEmpty(name))
            {
                name = "G" + (_guards.Count + 1);
            }
            else if (_guards.ContainsKey(name))
            {
                throw new CompilerException(ErrorCode.GuardNameReused, "guard '" + name + "' already exists.");
            }

            var guard = new Guard(name, gtype, c);
            _guards.Add(name, guard);
            return guard;
        }
示例#58
0
	public override void OnAwake()
	{
		_guard = GetComponent<Guard>();
	}
 public override void Awake()
 {
     base.Awake();
     guard = GetComponent<Guard>();
     initialSpeed = moveSpeed;
 }
        public void Register(IPlayer character)
        {
            IOutputService message = new ConsoleOutput();

            character.CharacterName = message.NamePrompt();

            character.Health = 100;
            character.SelectAction = ActionSelection.Attack;

            IEquipment weapon = null;

            string optionWeap = message.WeaponPrompt();
            Selection selectWeap = (Selection)Enum.Parse(typeof(Selection),
                                   optionWeap, true);

            switch (selectWeap)
            {
                case Selection.A:
                    {
                        weapon = new Knife();
                        break;
                    }
                case Selection.B:
                    {
                        weapon = new Sword();
                        break;
                    }
                case Selection.C:
                    {
                        weapon = new Blade();
                        break;
                    }
                case Selection.D:
                    {
                        weapon = new Katana();
                        break;
                    }
            }
            if (weapon != null)
            {
                character.WeaponName = weapon.EquipmentName;
                character.WeaponValue = message.AddEnchantment(weapon).EquipmentValue;
            }

            string optionArm = message.ArmorPrompt();
            Selection selectArm = (Selection)Enum.Parse(typeof(Selection),
                                  optionArm, true);

            IEquipment armor = null;

            switch (selectArm)
            {
                case Selection.A:
                    {
                        armor = new Guard();
                        break;
                    }
                case Selection.B:
                    {
                        armor = new Buckler();
                        break;
                    }
                case Selection.C:
                    {
                        armor = new Shield();
                        break;
                    }
                case Selection.D:
                    {
                        armor = new ThornShield();
                        break;
                    }
            }
            if (armor != null)
            {
                character.ArmorName = armor.EquipmentName;
                character.ArmorValue = message.AddEnchantment(armor).EquipmentValue;
            }
        }