Beispiel #1
0
 /// <summary>
 /// 根据兵种,取得预制件的名字
 /// </summary>
 /// <param name="soldierType_"></param>
 /// <returns></returns>
 public static string getPrefabName(Defaults.SoldierType soldierType)
 {
     if (_soldierPrefabs.ContainsKey(soldierType))
     {
         return _soldierPrefabs[soldierType];
     }
     return null;
 }
Beispiel #2
0
 /// <summary>
 /// 根据兵种,取得对应的类的type
 /// </summary>
 /// <param name="soldierScript"></param>
 /// <returns></returns>
 public static System.Type getClassType(Defaults.SoldierType soldierScript)
 {
     if (_soldierScripts.ContainsKey(soldierScript))
     {
         return _soldierScripts[soldierScript];
     }
     return null;
 }
		public ServerGameSettings()
		{
			var v = new Defaults();

			this.GetBoolean = v.GetBoolean;
			this.GetInteger = v.GetInteger;
			this.GetOption = v.GetOption;
			this.GetString = v.GetString;
		}
Beispiel #4
0
        public void AddDefault(string ext, string contentType)
        {
            if (string.IsNullOrEmpty(ext))
            {
                throw new ArgumentNullException(nameof(ext), "Invalid default content type extension");
            }
            if (string.IsNullOrEmpty(contentType))
            {
                throw new ArgumentNullException(nameof(contentType), "Invalid default content type");
            }

            Defaults.Add(ext, contentType);
        }
Beispiel #5
0
        private static void ResetSettings()
        {
            spikeHighlightEnabled          = Defaults.spikeHighlightEnabled;
            notificationEnabled            = Defaults.notificationEnabled;
            inspectorSpikeHighlightEnabled = Defaults.inspectorSpikeHighlightEnabled;
            monitoringUpdateSpeed          = Defaults.monitoringUpdateSpeed;
            notifications          = Defaults.GetDefaultNotifications();
            spikeWarningThreshold  = Defaults.spikeWarningThreshold;
            spikeCriticalThreshold = Defaults.spikeCriticalThreshold;

            spikeHighlightStrategy = Defaults.spikeHighlightStrategy;
            spikeDuration          = Defaults.spikeDuration;
        }
 /**
  * @param Defaults themingDefaults
  * @param IURLGenerator urlGenerator
  * @param IL10N l10n
  * @param string emailId
  * @param array data
  */
 public EMailTemplate(Defaults themingDefaults,
                      IURLGenerator urlGenerator,
                      IL10N l10n,
                      string emailId,
                      object data)
 {
     this.themingDefaults = themingDefaults;
     this.urlGenerator    = urlGenerator;
     this.l10n            = l10n;
     this.htmlBody       += this.head;
     this.emailId         = emailId;
     this.data            = data;
 }
Beispiel #7
0
        public SendSettings GetDeadLetterSettings(ISubscriptionConfigurator configurator, Uri hostAddress)
        {
            var description = configurator.GetSubscriptionDescription();

            var deadLetterEndpointAddress = new ServiceBusEndpointAddress(hostAddress, description.Name + DeadLetterQueueSuffix);

            var queueDescription = Defaults.CreateQueueDescription(deadLetterEndpointAddress.Path);

            queueDescription.DefaultMessageTimeToLive = description.DefaultMessageTimeToLive;
            queueDescription.AutoDeleteOnIdle         = description.AutoDeleteOnIdle;

            return(new QueueSendSettings(queueDescription));
        }
 /// <summary>
 /// This method will asynchronously load the <see cref="AsyncResourceFactory{TResource}"/> based on information in this <see cref="ResourceFactoryDynamicCreationFileBasedConfiguration"/>.
 /// </summary>
 /// <typeparam name="TResource">The type of the resources provided by returned <see cref="AsyncResourceFactory{TResource}"/>.</typeparam>
 /// <param name="configuration">This <see cref="ResourceFactoryDynamicCreationFileBasedConfiguration"/>.</param>
 /// <param name="assemblyLoader">The callback to asynchronously load assembly. The parameters are, in this order: package ID, package version, and path within the package.</param>
 /// <param name="token">The <see cref="CancellationToken"/> for this asynchronous operation.</param>
 /// <param name="creationParametersProvider">The optional callback to create creation parameters to bind the returned <see cref="AsyncResourceFactory{TResource}"/> to. Will be result of <see cref="Defaults.CreateDefaultCreationParametersProvider"/> if not provided here.</param>
 /// <returns>Asynchronously returns instance of <see cref="AsyncResourceFactory{TResource}"/>, or throws an exception.</returns>
 /// <exception cref="NullReferenceException">If this <see cref="ResourceFactoryDynamicCreationConfiguration"/> is <c>null.</c></exception>
 /// <exception cref="InvalidOperationException">If for some reason the <see cref="AsyncResourceFactory{TResource}"/> could not be loaded.</exception>
 public static Task <AsyncResourceFactory <TResource> > CreateAsyncResourceFactoryUsingConfiguration <TResource>(
     this ResourceFactoryDynamicCreationFileBasedConfiguration configuration,
     Func <String, String, String, CancellationToken, Task <Assembly> > assemblyLoader,
     CancellationToken token,
     Func <AsyncResourceFactoryProvider, Object> creationParametersProvider = null
     )
 {
     return(configuration.CreateAsyncResourceFactory <TResource>(
                assemblyLoader,
                creationParametersProvider ?? Defaults.CreateDefaultCreationParametersProvider(configuration),
                token
                ));
 }
        /// <summary>
        /// NewDeletableBloomFilter creates a new DeletableBloomFilter optimized to store
        /// n items with a specified target false-positive rate. The r value determines
        /// the number of bits to use to store collision information. This controls the
        /// deletability of an element. Refer to the paper for selecting an optimal value.
        /// </summary>
        /// <param name="n">Number of items</param>
        /// <param name="r">Number of bits to use to store collision information</param>
        /// <param name="fpRate">Desired false positive rate</param>
        public DeletableBloomFilter(uint n, uint r, double fpRate)
        {
            var m = Utils.OptimalM(n, fpRate);
            var k = Utils.OptimalK(fpRate);

            this.Buckets     = new Buckets(m - r, 1);
            this.Collisions  = new Buckets(r, 1);
            this.Hash        = Defaults.GetDefaultHashAlgorithm();
            this.M           = m - r;
            this.RegionSize  = (m - r) / r;
            this.k           = k;
            this.IndexBuffer = new uint[k];
        }
Beispiel #10
0
        /// <summary>
        /// Attempts to matche given route values to this parsed route, building up a probable path that
        /// could be used to navigate to this route.
        /// </summary>
        /// <param name="route">The route.</param>
        /// <param name="values">The values.</param>
        /// <returns>
        /// An object indicating the success or failure of the attempt to match the path.
        /// </returns>
        public PathMatch MatchRouteToPath(IRoute route, RouteValueDictionary values)
        {
            var valueBag      = new RouteValueBag(values);
            var segmentValues = new List <object>();

            foreach (var segment in Segments)
            {
                var match = segment.MatchValues(route, valueBag);
                if (match.Success)
                {
                    segmentValues.Add(match.SegmentValue);
                }
                else
                {
                    return(PathMatch.Failure(route, match.FailReason));
                }
            }

            var allValues = new RouteValueDictionary(Defaults);

            allValues.AddRange(values, true);
            allValues.AddRange(values, true);

            var leftOver = valueBag.GetRemaining();

            foreach (var leftOverItem in leftOver)
            {
                var key = leftOverItem.Key;
                if (Defaults.ContainsKey(key))
                {
                    var leftOverValue = leftOverItem.Value;
                    var defaultValue  = Defaults[leftOverItem.Key];

                    if ((leftOverValue == null || defaultValue == null) && (leftOverValue != defaultValue) ||
                        (leftOverValue != null && !leftOverValue.Equals(defaultValue)))
                    {
                        return(PathMatch.Failure(route, string.Format("The route was a close match, but the value of the '{0}' parameter was expected to be '{1}', but '{2}' was provided instead.", key, defaultValue, leftOverValue)));
                    }
                }
            }

            if (leftOver.Count > 0)
            {
                foreach (var defaultItem in Defaults.Where(item => leftOver.ContainsKey(item.Key)))
                {
                    leftOver.Remove(defaultItem.Key);
                }
            }

            return(PathMatch.Successful(route, allValues, leftOver, segmentValues));
        }
Beispiel #11
0
        public void DoList(Rect rect)
        {
            if (s_Defaults == null)
            {
                s_Defaults = new Defaults();
            }
            Rect headerRect = new Rect(rect.x, rect.y, rect.width, this.headerHeight);
            Rect listRect   = new Rect(rect.x, headerRect.y + headerRect.height, rect.width, this.GetListElementHeight());
            Rect footerRect = new Rect(rect.x, listRect.y + listRect.height, rect.width, this.footerHeight);

            this.DoListHeader(headerRect);
            this.DoListElements(listRect);
            this.DoListFooter(footerRect);
        }
        public async Task WhenInstanceCreated_ThenListLogEntriesReturnsInsertEvent(
            [LinuxInstance] InstanceRequest testInstance)
        {
            await testInstance.AwaitReady();

            var instanceRef = await testInstance.GetInstanceAsync();

            var loggingService = new LoggingService(new BaseClientService.Initializer
            {
                HttpClientInitializer = Defaults.GetCredential()
            });

            var startDate = DateTime.UtcNow.AddDays(-30);
            var endDate   = DateTime.UtcNow;

            var request = new ListLogEntriesRequest()
            {
                ResourceNames = new[]
                {
                    "projects/" + Defaults.ProjectId
                },
                Filter = $"resource.type=\"gce_instance\" " +
                         $"AND protoPayload.methodName:{InsertInstanceEvent.Method} " +
                         $"AND timestamp > {startDate:yyyy-MM-dd}",
                PageSize = 1000,
                OrderBy  = "timestamp desc"
            };

            var events          = new List <EventBase>();
            var instanceBuilder = new InstanceSetHistoryBuilder(startDate, endDate);

            // Creating the VM might be quicker than the logs become available.
            for (int retry = 0; retry < 4 && !events.Any(); retry++)
            {
                await loggingService.Entries.ListEventsAsync(
                    request,
                    events.Add,
                    new Apis.Util.ExponentialBackOff());

                if (!events.Any())
                {
                    await Task.Delay(20 * 1000);
                }
            }

            var insertEvent = events.OfType <InsertInstanceEvent>()
                              .First(e => e.InstanceReference == instanceRef);

            Assert.IsNotNull(insertEvent);
        }
Beispiel #13
0
        public void Defaults_WithEnvironment_ReturnsEnvironmentFallbackHosts()
        {
            var expectedFallBackHosts = new[]
            {
                "sandbox-a-fallback.ably-realtime.com",
                "sandbox-b-fallback.ably-realtime.com",
                "sandbox-c-fallback.ably-realtime.com",
                "sandbox-d-fallback.ably-realtime.com",
                "sandbox-e-fallback.ably-realtime.com",
            };
            var fallbackHosts = Defaults.GetEnvironmentFallbackHosts("sandbox");

            Assert.Equal(expectedFallBackHosts, fallbackHosts);
        }
        protected GameObject FileNameButtonRow(GameObject parent)
        {
            GameObject row = Row(parent, "FileNameButtonRow", TextAlignment.Left);

            Label(row, "FileNameLabel", "         FileName");
            ButtonProfile profile = Defaults.GetMomentaryButtonProfile(momentaryButtonProfile);

            GameObject fileNameObject = FileNameButton(fileSaveAs, row, profile, "FileName");

            fileNameButton            = fileNameObject.GetComponent <SaveAsFileNameButton>();
            fileSaveAs.fileNameButton = fileNameButton;
            Label(row, "ExtLabel", fileNameExtension);
            return(row);
        }
Beispiel #15
0
        public async Task WhenLoadAsyncCompletes_ThenOutputContainsExistingData(
            [WindowsInstance] InstanceRequest testInstance)
        {
            await testInstance.AwaitReady();

            var model = await SerialOutputModel.LoadAsync(
                new ComputeEngineAdapter(Defaults.GetCredential()),
                await testInstance.GetInstanceAsync(),
                SerialPortStream.ConsolePort,
                CancellationToken.None);

            Assert.IsFalse(string.IsNullOrWhiteSpace(model.Output));
            StringAssert.Contains("Instance setup finished", model.Output);
        }
Beispiel #16
0
        public void Options_WithCustomEnvironment()
        {
            var options = new ClientOptions
            {
                Environment = "sandbox"
            };

            options.FullRealtimeHost().Should().Be("sandbox-realtime.ably.io");
            options.FullRestHost().Should().Be("sandbox-rest.ably.io");
            options.Port.Should().Be(80);
            options.TlsPort.Should().Be(443);
            Assert.Equal(Defaults.GetEnvironmentFallbackHosts("sandbox"), options.GetFallbackHosts());
            options.Tls.Should().BeTrue();
        }
Beispiel #17
0
        public static async Task <bool> TryRenewToken(CTraderAccount account)
        {
            var connectAppInfo = Defaults.TryGet <ISpotwareConnectAppInfo>();

            if (connectAppInfo == null)
            {
                throw new ArgumentNullException("ISpotwareConnectAppInfo is not set in defaults.");
            }

            var renewUri = $"https://connect.spotware.com/apps/token?grant_type=refresh_token&refresh_token={account.Template.RefreshToken}&client_id={connectAppInfo.ClientPublicId}&client_secret={connectAppInfo.ClientSecret}";

            var client = NewHttpClient(isJson: true);

            var uri = renewUri;

            var response = await client.GetAsync(uri).ConfigureAwait(false);


            var receiveStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);

            System.IO.StreamReader readStream = new System.IO.StreamReader(receiveStream, System.Text.Encoding.UTF8);
            var json = readStream.ReadToEnd();
            var data = Newtonsoft.Json.JsonConvert.DeserializeObject <SpotwareRenewTokenResult>(json);

            if (!response.IsSuccessStatusCode || data.errorCode != null)
            {
                Debug.WriteLine("Failed refresh response: " + json);
            }

            if (!response.IsSuccessStatusCode)
            {
                switch (response.StatusCode)
                {
                case System.Net.HttpStatusCode.NotFound:

                default:
                    throw new Exception("Refresh failed with HTTP status code: " + response.StatusCode + " " + response.ReasonPhrase);
                }
            }

            if (data.errorCode == null && !string.IsNullOrEmpty(data.accessToken))
            {
                account.Template.AccessToken  = data.accessToken;
                account.Template.RefreshToken = data.refreshToken;
                throw new NotImplementedException("TODO: Sort out the Save call");
                //await account.Template.Save(new PersistenceContext { AllowInstantiator = false});
                //return true;
            }
            return(false);
        }
Beispiel #18
0
        public void SetComponents()
        {
            // Form
            this.StartPosition = Defaults.frmStartPointAtParentCenter;
            this.Font          = Defaults.microsoftSansSerif12Bold;
            this.Icon          = Defaults.getIconByName("mais1");
            this.Text          = "Cliente";
            // Group Box
            GrpBox_Endereco.Text = "Endereço";
            GrpBox_Sobre.Text    = "Inf. Pessoais";
            Grp_Contato.Text     = "Contato";
            // Label
            Lbl_Titulo.Font = Defaults.fontPadraoTituloJanelas16Bold;

            Lbl_Bairro.Text     = "Bairro";
            Lbl_CEP.Text        = "CEP";
            Lbl_Cidade.Text     = "Cidade";
            Lbl_DataNsc.Text    = "Data Nasc.";
            Lbl_Logradouro.Text = "Logradouro";
            Lbl_Nome.Text       = "Nome";
            Lbl_Titulo.Text     = "Cliente";
            Lbl_UF.Text         = "UF";
            Lbl_Telefone1.Text  = "Telefone";
            Lbl_Telefone2.Text  = "Telefone 2";
            Lbl_Email.Text      = "E-mail";
            Lbl_CPF.Text        = "CPF";
            // Text Box
            // Masked Text Box
            MskBox_DataNsc.Mask      = Defaults.dataMask;
            MskTxtBox_CEP.Mask       = Defaults.cepMask;
            MskTxtBox_CPF.Mask       = Defaults.cpfMask;
            MskTxtBox_Telefone1.Mask = Defaults.telefoneMask;
            MskTxtBox_Telefone2.Mask = Defaults.telefoneMask;
            // Picture Box
            //PicBox_Logo.SizeMode = Defaults.stretchImageStyle;
            //PicBox_Logo.Image = Defaults.getImageByName("user");
            // Button
            Btn_Voltar.Text      = "Voltar";
            Btn_Novo_Salvar.Text = "Novo";
            Btn_Limpar.Text      = "Limpar Campos";
            Btn_Editar.Text      = "Editar";
            Btn_Excluir.Text     = "Excluir";
            Btn_Pesquisar.Text   = "Pesquisar";
            // Combo Box
            CmbBox_UF.Items.Clear();
            CmbBox_UF.Items.AddRange(Defaults.enumEstados());

            DefinirEditabilidadeDosCampos(false);
            Btn_Pesquisar.Enabled = true;
        }
Beispiel #19
0
        protected override void SaveTo(IObjectData data, bool omitDefault)
        {
            // argument checks
            Debug.Assert(data != null);

            // save settings
            data.SetStringValue(SettingNames.EndPoint, this.EndPoint, omitDefault, Defaults.IsDefaultEndPoint(this.EndPoint));
            data.SetStringValue(SettingNames.UserName, this.UserName, omitDefault, Defaults.IsDefaultUserName(this.UserName));
            data.SetValue(SettingNames.ProtectedPassword, this.Password, CreatePasswordValue, omitDefault, Defaults.IsDefaultPassword(this.Password));
            data.SetEnumValue(SettingNames.Persistence, this.Persistence, omitDefault, this.Persistence == Defaults.Persistence);
            data.SetBooleanValue(SettingNames.EnableAssumptionMode, this.EnableAssumptionMode, omitDefault, this.EnableAssumptionMode == Defaults.EnableAssumptionMode);

            return;
        }
 void ISerializableComponent.ApplyData(SerializableComponentData data)
 {
     if (data is RibbonSketchObjectData ribbonData)
     {
         RibbonMesh = new RibbonMesh(ribbonData.CrossSectionVertices, ribbonData.CrossSectionScale);
         SetControlPointsLocalSpace(ribbonData.ControlPoints, ribbonData.ControlPointOrientations);
         meshRenderer.sharedMaterial = Defaults.GetMaterialFromDictionary(ribbonData.SketchMaterial);
         ribbonData.ApplyDataToTransform(this.transform);
     }
     else
     {
         Debug.LogError("Invalid data for RibbonSketchObject.");
     }
 }
Beispiel #21
0
        public IRedirectMapper To(object values)
        {
            // we need a set of values that this route can resolve to
            // if you didn't use the Default, let's just resolve it
            // to the same thing we are redirecting to.
            if (Defaults == null || !Defaults.Any())
            {
                Defaults = new RouteValueDictionary(values);
            }

            DataTokens["new_path"] = new RouteValueDictionary(values);

            return(this);
        }
Beispiel #22
0
        /// <summary>
        /// Gets the value or its default.
        /// </summary>
        /// <typeparam name="T">The type.</typeparam>
        /// <param name="key">The key.</param>
        /// <returns>The value.</returns>
        public T GetOrDefault <T>(string key)
        {
            Guard.AgainstNullAndEmpty(nameof(key), key);
            if (Overrides.TryGetValue(key, out var result))
            {
                return((T)result);
            }

            if (Defaults.TryGetValue(key, out result))
            {
                return((T)result);
            }

            return(default);
Beispiel #23
0
        public T GetDefault(Characteristics characteristics, string template = null)
        {
            template = template ?? DefaultTemplateName;

            if (characteristics == null)
            {
                throw new InvalidOperationException("Can't have a null characteristics; use Characteristics.None");
            }

            //check for characteristics
            if (!CharacteristicsTransitionMethods.ContainsKey(characteristics))
            {
                throw new Exception($"unknown characteristics:{characteristics}");
            }

            if (!Defaults.ContainsKey(characteristics))
            {
                Defaults.Add(characteristics, new Dictionary <string, Lazy <T> >());
            }

            if (!Defaults[characteristics].ContainsKey(template))
            {
                //initialize
                Func <T> factory = () =>
                {
                    var ret = ObjectFactory.CreateInstance <T>();
                    if (TemplateManager == null && template != null)
                    {
                        throw new NullReferenceException("No template manager was provided");
                    }

                    if (template == DefaultTemplateName)
                    {
                        TemplateManager?.ApplyTemplate(ret);
                    }
                    else
                    {
                        TemplateManager?.ApplyTemplate(ret, template);
                    }

                    DecorateNewItem(ret);
                    CharacteristicsTransitionMethods[characteristics](ret);
                    return(ret);
                };
                Defaults[characteristics].Add(template, new Lazy <T>(factory));
            }

            return(Defaults[characteristics][template].Value);
        }
Beispiel #24
0
        public async Task WhenInstanceExistsAndIsListening_ThenProbeSucceeds(
            [WindowsInstance] InstanceRequest testInstance)
        {
            await testInstance.AwaitReady();

            using (var stream = new SshRelayStream(
                       new IapTunnelingEndpoint(
                           Defaults.GetCredential(),
                           testInstance.InstanceReference,
                           3389,
                           IapTunnelingEndpoint.DefaultNetworkInterface)))
            {
                await stream.TestConnectionAsync(TimeSpan.FromSeconds(10));
            }
        }
Beispiel #25
0
        public static RdpTunnel Create(VmInstanceReference vmRef)
        {
            var listener = SshRelayListener.CreateLocalListener(
                new IapTunnelingEndpoint(
                    Defaults.GetCredential(),
                    vmRef,
                    3389,
                    IapTunnelingEndpoint.DefaultNetworkInterface));

            var tokenSource = new CancellationTokenSource();

            listener.ListenAsync(tokenSource.Token);

            return(new RdpTunnel(listener, tokenSource));
        }
Beispiel #26
0
        public bool Matches(RouteValueDictionary rvs)
        {
            Dictionary <string, object> adjustedRvs = rvs.ToDictionary(rv => rv.Key, rv => rv.Value); // clone

            if (adjustedRvs.ContainsKey("originalAction"))
            {
                adjustedRvs["action"] = adjustedRvs["originalAction"];
                adjustedRvs.Remove("originalAction");
            }
            return(adjustedRvs.All(kvp => kvp.Key == "controller" ||
                                   !Defaults.ContainsKey(kvp.Key) ||
                                   Defaults.Contains(kvp) ||
                                   UrlVariables.Contains(kvp.Key)) &&
                   UrlVariables.All(uv => adjustedRvs.ContainsKey(uv)));
        }
        public TestController(
            ITestService testService,
            IQuestionService questionService,
            IAnswerService answerService,
            IAuthenticationManager authManager,
            IMapper mapper)
        {
            _testService     = testService;
            _questionService = questionService;
            _answerService   = answerService;
            _authManager     = authManager;
            _mapper          = mapper;

            pageSize = Defaults.GetPageSize();
        }
Beispiel #28
0
        /// <summary>
        /// Gets the given value by key.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns>The value.</returns>
        public object Get(string key)
        {
            Guard.AgainstNullAndEmpty(nameof(key), key);
            if (Overrides.TryGetValue(key, out var result))
            {
                return(result);
            }

            if (Defaults.TryGetValue(key, out result))
            {
                return(result);
            }

            throw new KeyNotFoundException($"The given key ({key}) was not present in the dictionary.");
        }
Beispiel #29
0
        static QueueDescription GetQueueDescription(Uri address)
        {
            var queueName = address.AbsolutePath.Trim('/');

            var queueDescription = Defaults.CreateQueueDescription(queueName);

            var autoDeleteOnIdleSeconds = address.GetValueFromQueryString("autodelete", 0);

            if (autoDeleteOnIdleSeconds > 0)
            {
                queueDescription.AutoDeleteOnIdle = TimeSpan.FromSeconds(autoDeleteOnIdleSeconds);
            }

            return(queueDescription);
        }
        private GameObject CreateColorHuePickerThumb(GameObject parent)
        {
            GameObject         thumb      = EmptyChild(parent, "ColorHuePickerThumb");
            MeshFilter         meshFilter = Undoable.AddComponent <MeshFilter>(thumb);
            ColorPickerProfile profile    = Defaults.GetProfile(colorPickerProfile);

            meshFilter.sharedMesh         = profile.thumbBody.GetComponent <MeshFilter>().sharedMesh;
            thumb.transform.localPosition = profile.hueThumbLocalPosition;
            thumb.transform.localScale    = profile.hueThumbScale;
            MeshRenderer meshRenderer = Undoable.AddComponent <MeshRenderer>(thumb);

            meshRenderer.materials = new Material[] { profile.thumbMaterial };

            return(thumb);
        }
        protected GameObject ButtonSpacer(GameObject parent, float width)
        {
            ButtonProfile       profile = Defaults.GetMomentaryButtonProfile(momentaryButtonProfile);
            ButtonSpacerFactory factory = Undoable.AddComponent <ButtonSpacerFactory>(disposable);

            factory.parent = parent;
            Vector3 size = profile.bodyScale;

            size.x       = width;
            factory.size = size;
            GameObject button = factory.Generate();

            SetKeyboardButtonPosition(button);
            return(button);
        }
        public ServiceBusBusFactoryConfigurator()
        {
            _hosts = new BusHostCollection <ServiceBusHost>();

            var queueName = ((IServiceBusHost)null).GetTemporaryQueueName("bus");

            _settings = new ReceiveEndpointSettings(Defaults.CreateQueueDescription(queueName))
            {
                QueueDescription =
                {
                    EnableExpress    = true,
                    AutoDeleteOnIdle = TimeSpan.FromMinutes(5)
                }
            };
        }
        public async Task WhenImageNotFound_ThenAnnotationNotAdded()
        {
            var annotatedSet = CreateSet(
                new ImageLocator("unknown", "beos"));

            Assert.AreEqual(0, annotatedSet.LicenseAnnotations.Count());

            var computeEngineAdapter = new ComputeEngineAdapter(Defaults.GetCredential());
            await LicenseLoader.LoadLicenseAnnotationsAsync(
                annotatedSet,
                computeEngineAdapter,
                CancellationToken.None);

            Assert.AreEqual(0, annotatedSet.LicenseAnnotations.Count());
        }
Beispiel #34
0
 public Recognize(string fileName, Defaults defaults)
 {
     this.defaults = defaults;
     if (String.IsNullOrEmpty(fileName) || !File.Exists(fileName))
     {
         exception = new Exception("File name is incorrect: " + fileName);
         NotifyUpdated(NotifyKey.Exception, exception);
         return;
     }
     FileName = fileName;
     FileNameAudit = fileName.Replace(new FileInfo(fileName).Extension, ".audit");
     #region Get Bitmap
     PDFLibNet.PDFWrapper pdfDoc = null;
     try
     {
         Image = Utils.GetBitmapFromFile(FileName, ref pdfDoc);
         Image = Utils.NormalizeBitmap(Image);
         Image = RecognitionTools.GetMonohromeNoIndexBitmap(Image);
     }
     catch (Exception ex)
     {
         exception = ex;
         NotifyUpdated(NotifyKey.Exception, exception);
         return;
     }
     finally
     {
         if (pdfDoc != null)
         {
             pdfDoc.Dispose();
             pdfDoc = null;
         }
     }
     #endregion
     #region Get audit file
     FileAudit = Utils.GetAuditFromFile(FileNameAudit, out exception);
     if (FileAudit == null)
     {
         NotifyUpdated(NotifyKey.Exception, exception);
         return;
     }
     #endregion
     regionsExt = RecognitionTools.GetRegionsExt(out sheetIdentifiers, Defaults.ManualConfigsFolder);
 }
Beispiel #35
0
    /// <summary>
    /// 添加一个士兵
    /// </summary>
    /// <param name="soldierType">士兵类型</param>
    /// <returns>Soldier</returns>
    //public Soldier createSoldier(Defaults.SoldierType type)
    public void createSoldier(Defaults.SoldierType type)
    {
        //取得预制件名
        string prefab = ResourceConfig.getPrefabName(type);

        //实例化预制件
        GameObject gameObj = ResourceManager.getInstance().getGameObject(prefab);

        //缩放
        // gameObj.transform.localScale = new Vector3(Defaults.SOLDIER_SCALE, Defaults.SOLDIER_SCALE, Defaults.SOLDIER_SCALE);

        //绑定脚本
        //UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent(gameObj, "add cs to soldier", ScriptsList.getScript(type));

        //取得脚本
        //Soldier script = (Soldier)gameObj.GetComponent(ScriptsList.getScript(type));
        //script.Type = type;
        //return script;

        return;
    }
Beispiel #36
0
    /// <summary>
    /// 添加一个士兵——————测试用
    /// </summary>
    /// <param name="country"></param>
    /// <param name="x_"></param>
    /// <param name="y_"></param>
    public void addSoldier(SoldierDataBase data, Defaults.SoldierType soldierType, Vector3 point)
    {
        //复制预制件
        GameObject soldierBody = ResourceManager.getInstance().getGameObject(ResourceConfig.getPrefabName(soldierType));
        soldierBody.name = null;

        if (data == null)
        {
            return;
        }

        if (data.Country == Defaults.Country.Me)
        {
            soldierBody.name = "me" + sprId;
        }
        else
        {
            soldierBody.name = "enemy" + sprId;
        }
        sprId++;

        //如果取得预制件失败,返回
        if(soldierBody == null)
        {
            return;
        }

        //根据兵种实例化兵种类,绑定到预制件
        Type scriptType = ResourceConfig.getClassType(soldierType);
        soldierBody.AddComponent(scriptType);
        GeneralSoldier soldierScript = soldierBody.GetComponent(scriptType) as GeneralSoldier;
        //如果取得脚本失败,返回
        if (soldierScript == null)
        {
            return;
        }

        //设置属性
        soldierScript._data = data;//势力
        soldierScript._data.DeadDelay = 10;
        soldierScript._data.SkillMgr.setSkills(soldierScript);//技能
        int distance = data.Country == Defaults.Country.Me ? 14 : 26;//敌我距离
        soldierBody.transform.Rotate(0, data.Country == Defaults.Country.Me ? 0 : 180, 0);//设置敌我部队的朝向
        soldierBody.transform.position = point;//设置坐标

        //存进士兵容器
        if (data.Country == Defaults.Country.Enemy)
        {
            _enemySoldiers.Add(soldierScript);
        }
        else
        {
            _selfSoldiers.Add(soldierScript);
        }
    }
Beispiel #37
0
	/// <summary>
	/// Updates the inspector.
	/// </summary>
	public override void UpdateInspector()
	{
		if (_lastDefaults != SetDefaultsTo)
		{
			CleanSupportedTriggers();
	        SupportedTriggers = null;
	        InitializeSupportedTriggers();
			_lastDefaults = SetDefaultsTo;
		}		
	}
Beispiel #38
0
        /// <summary>
        /// Get defaults from defaults.xml and add default properties using reflection
        /// </summary>
        public void SetDefaults(String DefaultsXml)
        {
            Defaults defaults = new Defaults(DefaultsXml);

            //Only get default values for public properties
            PropertyInfo[] properties = this.GetType().GetProperties();

            foreach (var item in properties)
            {
                object defaultVal = defaults.GetDefaultValue(this.GetType(), item);
                if(defaultVal != null) item.SetValue(this, defaultVal, null);
            }
        }
Beispiel #39
0
 /// <summary>
 /// 获得对手精灵集合
 /// </summary>
 /// <param name="coutry"></param>
 /// <returns></returns>
 public IList<XLSpriteBase> getMatchSprites(Defaults.Country coutry)
 {
     IList<XLSpriteBase> matchSprites = null;
     if (coutry == Defaults.Country.Enemy)
     {
         matchSprites = _selfSoldiers;
     }
     else if (coutry == Defaults.Country.Me || coutry == Defaults.Country.Friend)
     {
         matchSprites = _enemySoldiers;
     }
     return matchSprites;
 }
Beispiel #40
0
    /// <summary>
    /// 根据类型获取空闲的士兵
    /// </summary>
    /// <param name="type"></param>
    /// <returns></returns>
    //public Soldier getFreeSoldier(Defaults.SoldierType type)
    public void getFreeSoldier(Defaults.SoldierType type)
    {
        if (type == Defaults.SoldierType.Bowman)
        {
            //return _freeBowmanPool.getFreeChild();
        }

        if (type == Defaults.SoldierType.Cavalryman)
        {
            //return _freeCavalrymanPool.getFreeChild();
        }

        if (type == Defaults.SoldierType.Swordman)
        {
            //return _freeSwordmanPool.getFreeChild();
        }

        //return null;
        return;
    }
Beispiel #41
0
 public void DoLayoutList()
 {
     if (s_Defaults == null)
     {
         s_Defaults = new Defaults();
     }
     GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.ExpandWidth(true) };
     Rect headerRect = GUILayoutUtility.GetRect((float) 0f, this.headerHeight, options);
     GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.ExpandWidth(true) };
     Rect listRect = GUILayoutUtility.GetRect((float) 10f, this.GetListElementHeight(), optionArray2);
     GUILayoutOption[] optionArray3 = new GUILayoutOption[] { GUILayout.ExpandWidth(true) };
     Rect footerRect = GUILayoutUtility.GetRect((float) 4f, this.footerHeight, optionArray3);
     this.DoListHeader(headerRect);
     this.DoListElements(listRect);
     this.DoListFooter(footerRect);
 }
Beispiel #42
0
 public void DoList(Rect rect)
 {
     if (s_Defaults == null)
     {
         s_Defaults = new Defaults();
     }
     Rect headerRect = new Rect(rect.x, rect.y, rect.width, this.headerHeight);
     Rect listRect = new Rect(rect.x, headerRect.y + headerRect.height, rect.width, this.GetListElementHeight());
     Rect footerRect = new Rect(rect.x, listRect.y + listRect.height, rect.width, this.footerHeight);
     this.DoListHeader(headerRect);
     this.DoListElements(listRect);
     this.DoListFooter(footerRect);
 }
Beispiel #43
0
 private static void CreateInstance()
 {
     print("Load Defaults");
     instance=Resources.Load("Defaults", typeof(Defaults)) as Defaults;
 }