public static string SelecionaChaveParametroTipoMovimentacao
 (
     ChaveParametroTipoMovimentacao chave
 )
 {
     return(StringValueAttribute.GetStringValue(chave));
 }
        /// <summary>
        /// Only intended to be used by the EntityFramework itself! Creates the native property information for a reflected managed property and returns the created managed EntityProperty. Returns 'null', if the property is not marked as 'EntityProperty', or no property converter can be found for the type of the property.
        /// </summary>
        /// <param name="managed">Managed.</param>
        internal static EntityProperty Create(PropertyInfo managed)
        {
            EntityPropertyAttribute attrib = (EntityPropertyAttribute)managed.GetCustomAttributes(typeof(EntityPropertyAttribute), true).FirstOrDefault();

            if (attrib == null)
            {
                return(null);
            }

            if (!s_converters.ContainsKey(managed.PropertyType))
            {
                return(null);
            }

            EEditTypes editType = attrib.EditType;

            if (editType == EEditTypes.Default)
            {
                editType = s_converters [managed.PropertyType].DefaultEditType;
            }
            string strEditType = StringValueAttribute.GetStringValue(editType);

            IEntityPropertyHandler.SPropertyInfo engine = new IEntityPropertyHandler.SPropertyInfo();
            engine.name        = managed.Name;
            engine.description = attrib.Description;
            engine.editType    = strEditType;
            engine.limits      = new IEntityPropertyHandler.SPropertyInfo.SLimits();
            engine.limits.min  = attrib.Min;
            engine.limits.max  = attrib.Max;
            engine.type        = s_converters [managed.PropertyType].EngineType;

            return(new EntityProperty(managed, engine, attrib.Default));
        }
Exemple #3
0
        /// <summary>
        /// Gets a property's value.
        /// </summary>
        /// <param name="prop">The <see cref="PropertyInfo"/> object.</param>
        /// <param name="obj">The target object.</param>
        /// <returns>The string value.</returns>
        public static string GetPropValue(PropertyInfo prop, object obj)
        {
            var val = prop.GetValue(obj, null);

            if (val == null)
            {
                return(null);
            }

            if (val is bool boolVal)
            {
                return(boolVal ? "1" : "0");
            }

            if (val is Enum enumVal)
            {
                return(StringValueAttribute.GetStringValue(enumVal));
            }

            if (val is IEnumerable <Enum> enumVals)
            {
                return(enumVals.Select(x => StringValueAttribute.GetStringValue(x))
                       .Aggregate((ret, x) => $"{ret},{x}"));
            }

            if (val is IEnumerable <string> strVals)
            {
                return(strVals.Aggregate((ret, x) => $"{ret},{x}"));
            }

            if (val is IEnumerable <int> intVals)
            {
                return(intVals.Select(x => $"{x}")
                       .Aggregate((ret, x) => $"{ret},{x}"));
            }

            if (val is IEnumerable <long> longVals)
            {
                return(longVals.Select(x => $"{x}")
                       .Aggregate((ret, x) => $"{ret},{x}"));
            }

            var converterAttrType = typeof(JsonConverterAttribute);

            if (prop.GetCustomAttribute(converterAttrType) is JsonConverterAttribute converterAttr)
            {
                var converters = new[]
                {
                    (JsonConverter)Activator.CreateInstance(converterAttr.ConverterType),
                };

                return(JsonConvert.SerializeObject(val, converters));
            }

            return(val.ToString());
        }
        public bool DiscoverDevices(string name)
        {
            ICardDevice device = DeviceProvider.GetDevice(name);

            if (device == null)
            {
                throw new Exception(StringValueAttribute.GetStringValue(DeviceDiscovery.NoDeviceAvailable));
            }

            return(device.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
        }
        public static string SelecionaValorParametroTipoMovimentacao
        (
            int tmo_id
            , ChaveParametroTipoMovimentacao chave
        )
        {
            string valorChave = StringValueAttribute.GetStringValue(chave);

            MTR_ParametroTipoMovimentacaoDAO dao = new MTR_ParametroTipoMovimentacaoDAO();

            return(dao.SelectBy_ptm_chave(tmo_id, valorChave));
        }
        /// <summary>
        /// Retorna os parâmetros cadastrados para o parâmetro de movimentação
        /// </summary>
        /// <param name="valor"></param>
        /// <param name="chave">Chave</param>
        /// <returns></returns>
        public static bool VerificaValorParametroTipoMovimentacao
        (
            string valor
            , ChaveParametroTipoMovimentacao chave
        )
        {
            string valorChave = StringValueAttribute.GetStringValue(chave);

            MTR_ParametroTipoMovimentacaoDAO dao = new MTR_ParametroTipoMovimentacaoDAO();

            return(dao.SelectBy_ptm_chave_valor(valor, valorChave));
        }
        private ILocalizedTextRegistry FindRegistry()
        {
            var tagname  = StringValueAttribute.GetStringValue(Tags.Localization);
            var registry = GameObject.FindGameObjectWithTag(tagname);

                        #if UNITY_EDITOR
            if (registry == null)
            {
                Debug.LogWarning("Registry not found");
            }
                        #endif

            return((registry == null)? null : registry.GetComponent <ILocalizedTextRegistry>());
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public HttpRequestMessage CreateRequest(BaseRestService service)
        {
            HttpRequestMessage request = new HttpRequestMessage(new HttpMethod(StringValueAttribute.GetStringValue(this.HttpMethod)), BuildUrl());

            request.Headers.Authorization = new AuthenticationHeaderValue("Basic", Utilities.EncodeCredentials(service.Credentials.ApiKey, service.Credentials.SecretKey));
            request.Headers.Add("Y-Client-Type", ".NET");
            request.Headers.Add("Y-Client-Info", service.GetType().GetTypeInfo().Assembly.FullName);

#if NETSTANDARD1_3
            request.Headers.Add("Y-Client-Platform", System.Runtime.InteropServices.RuntimeInformation.OSDescription);
#else
            request.Headers.Add("Y-Client-Platform", System.Environment.OSVersion.ToString());
#endif

            if (service.CustomHeaders != null && service.CustomHeaders.Count > 0)
            {
                foreach (var customHeader in service.CustomHeaders)
                {
                    request.Headers.Add(customHeader.Key, customHeader.Value);
                }
            }

            return(request);
        }
 public void DiscoverDevice_ShouldReturnTrue_WhenVerifoneDeviceProviderIsVerifone()
 {
     Devices.Common.Interfaces.ICardDevice device = new VerifoneDevice();
     mockDeviceProvider.Setup(e => e.GetDevice(It.IsAny <string>())).Returns(device);
     Assert.True(subject.DiscoverDevices(StringValueAttribute.GetStringValue(DeviceType.Verifone)));
 }
Exemple #10
0
 /// <summary>
 /// Get name of target folder in StreamingAssets.
 /// </summary>
 /// <returns></returns>
 private static string GetTargetFolderName()
 {
     return(StringValueAttribute.GetStringValue(StreamingAssetsPathSubfolder.Localization));
 }
Exemple #11
0
        public void TestStaticRoomLifecycleAsyncCallback()
        {
            const string roomName        = "Room Lifecycle {0}";
            const string roomDescription = "Description of the room lifecycle {0}";

            TestStaticCreateRoomAsyncCallback(
                roomId => TestStaticPutRoomAsyncCallback(
                    roomId,
                    roomId => TestStaticGetRoomAsyncCallback(
                        roomId,
                        TestStaticDeleteRoomAsyncCallback)));

            // [POST] /rooms.
            void TestStaticCreateRoomAsyncCallback(Action <long> next)
            {
                var identifier = "New";
                var parameters = new NewRoomParameters
                {
                    Description        = string.Format(CultureInfo.InvariantCulture, roomDescription, identifier),
                    IconPreset         = IconPresetValue.Group,
                    Link               = false,
                    LinkCode           = "weqxdfas",
                    LinkNeedAcceptance = true,
                    MembersAdminIds    = new[] { AccountId },
                    MembersMemberIds   = null,
                    MembersReadonlyIds = null,
                    Name               = string.Format(CultureInfo.InvariantCulture, roomName, identifier),
                };

                ChatworkClient.PostRoomAsync(
                    Token,
                    response =>
                {
                    AssertPostRoomsResponse(response);
                    next.Invoke(response.Data.RoomId);
                },
                    parameters);
            }

            // [GET] /rooms/{room_id}.
            void TestStaticGetRoomAsyncCallback(long roomId, Action <long> next)
            {
                ChatworkClient.GetRoomAsync(
                    Token,
                    response =>
                {
                    AssertGetRoomResponse(response, roomId);
                    next.Invoke(roomId);
                },
                    roomId);
            }

            // [PUT] /rooms/{room_id}.
            void TestStaticPutRoomAsyncCallback(long roomId, Action <long> next)
            {
                var iconPreset = IconPresetValue.Business;
                var identifier = StringValueAttribute.GetStringValue(iconPreset);
                var parameters = new UpdateRoomParameters
                {
                    Description = string.Format(CultureInfo.InvariantCulture, roomDescription, identifier),
                    IconPreset  = iconPreset,
                    Name        = string.Format(CultureInfo.InvariantCulture, roomName, identifier),
                };

                ChatworkClient.PutRoomAsync(
                    Token,
                    response =>
                {
                    AssertPutRoomResponse(response, roomId);
                    next.Invoke(roomId);
                },
                    roomId,
                    parameters);
            }

            // [DELETE] /rooms/{room_id}.
            void TestStaticDeleteRoomAsyncCallback(long roomId)
            {
                var parameters = new DeleteRoomParameters
                {
                    ActionType = ActionTypeValue.Leave,
                };

                ChatworkClient.DeleteRoomAsync(
                    Token,
                    response => AssertDeleteRoomResponse(response),
                    roomId,
                    parameters);
            }
        }
Exemple #12
0
        public void TestRoomLifecycle()
        {
            const string roomName        = "Room Lifecycle {0}";
            const string roomDescription = "Description of the room lifecycle {0}";
            var          roomId          = TestCreateRoom();

            TestGetRoom(roomId);
            TestPutRoom(roomId);
            TestDeleteRoom(roomId);

            // [POST] /rooms.
            long TestCreateRoom()
            {
                var identifier = "New";
                var parameters = new NewRoomParameters
                {
                    Description        = string.Format(CultureInfo.InvariantCulture, roomDescription, identifier),
                    IconPreset         = IconPresetValue.Group,
                    Link               = false,
                    LinkCode           = "jlklqwes",
                    LinkNeedAcceptance = true,
                    MembersAdminIds    = new[] { AccountId },
                    MembersMemberIds   = MemberList,
                    MembersReadonlyIds = null,
                    Name               = string.Format(CultureInfo.InvariantCulture, roomName, identifier),
                };

                var response = Client.PostRoom(parameters);

                AssertPostRoomsResponse(response);
                return(response.Data.RoomId);
            }

            // [GET] /rooms/{room_id}.
            void TestGetRoom(long roomId)
            {
                var response = Client.GetRoom(roomId);

                AssertGetRoomResponse(response, roomId);
            }

            // [PUT] /rooms/{room_id}.
            void TestPutRoom(long roomId)
            {
                var iconPresetList = Enum.GetValues(typeof(IconPresetValue));

                foreach (IconPresetValue iconPreset in iconPresetList)
                {
                    var identifier = string.Format(
                        CultureInfo.InvariantCulture,
                        "[{0}]",
                        StringValueAttribute.GetStringValue(iconPreset));

                    var parameters = new UpdateRoomParameters
                    {
                        Description = string.Format(CultureInfo.InvariantCulture, roomDescription, identifier),
                        IconPreset  = iconPreset,
                        Name        = string.Format(CultureInfo.InvariantCulture, roomName, identifier),
                    };

                    var response = Client.PutRoom(roomId, parameters);
                    AssertPutRoomResponse(response, roomId);
                }
            }

            // [DELETE] /rooms/{room_id}.
            void TestDeleteRoom(long roomId)
            {
                var parameters = new DeleteRoomParameters
                {
                    ActionType = ActionTypeValue.Delete,
                };

                var response = Client.DeleteRoom(roomId, parameters);

                AssertDeleteRoomResponse(response);
            }
        }
Exemple #13
0
        public async void TestRoomLifecycleAsync()
        {
            const string roomName        = "Room Lifecycle {0}";
            const string roomDescription = "Description of the room lifecycle {0}";

            var roomId = await TestCreateRoomAsync()
                         .ConfigureAwait(false);

            await TestPutRoomAsync(roomId)
            .ConfigureAwait(false);

            await TestGetRoomAsync(roomId)
            .ConfigureAwait(false);

            await TestDeleteRoomAsync(roomId)
            .ConfigureAwait(false);

            // [POST] /rooms.
            async Task <long> TestCreateRoomAsync()
            {
                var identifier = "New";
                var parameters = new NewRoomParameters
                {
                    Description        = string.Format(CultureInfo.InvariantCulture, roomDescription, identifier),
                    IconPreset         = IconPresetValue.Group,
                    Link               = false,
                    LinkCode           = "weqxdfas",
                    LinkNeedAcceptance = true,
                    MembersAdminIds    = new[] { AccountId },
                    MembersMemberIds   = null,
                    MembersReadonlyIds = MemberList,
                    Name               = string.Format(CultureInfo.InvariantCulture, roomName, identifier),
                };

                var response = await Client.PostRoomAsync(parameters)
                               .ConfigureAwait(false);

                AssertPostRoomsResponse(response);
                return(response.Data.RoomId);
            }

            // [GET] /rooms/{room_id}.
            async Task TestGetRoomAsync(long roomId)
            {
                var response = await Client.GetRoomAsync(roomId)
                               .ConfigureAwait(false);

                AssertGetRoomResponse(response, roomId);
            }

            // [PUT] /rooms/{room_id}.
            async Task TestPutRoomAsync(long roomId)
            {
                var iconPreset = IconPresetValue.Business;
                var identifier = StringValueAttribute.GetStringValue(iconPreset);
                var parameters = new UpdateRoomParameters
                {
                    Description = string.Format(CultureInfo.InvariantCulture, roomDescription, identifier),
                    IconPreset  = iconPreset,
                    Name        = string.Format(CultureInfo.InvariantCulture, roomName, identifier),
                };

                var response = await Client.PutRoomAsync(roomId, parameters)
                               .ConfigureAwait(false);

                AssertPutRoomResponse(response, roomId);
            }

            // [DELETE] /rooms/{room_id}.
            async Task TestDeleteRoomAsync(long roomId)
            {
                var parameters = new DeleteRoomParameters
                {
                    ActionType = ActionTypeValue.Leave,
                };

                var response = await Client.DeleteRoomAsync(roomId, parameters)
                               .ConfigureAwait(false);

                AssertDeleteRoomResponse(response);
            }
        }