/// <summary>
        /// Get the module fields data for the module with this name, if any.
        /// </summary>
        /// <param name="module">the name of the module to query.</param>
        /// <returns>A structure of module's fields data.</returns>
        public static ModuleFields GetFieldsForModule(string module)
        {
            ModuleFields result;
            /* module name is case sensitive, initial capital */
            string moduleName = char.ToUpper(module[0]) + module.Substring(1);

            if (RestAPIWrapper.moduleFieldsCache.ContainsKey(moduleName))
            {
                result = RestAPIWrapper.moduleFieldsCache[moduleName];
            }
            else
            {
                if (!string.IsNullOrEmpty(module) && SuiteCRMUserSession != null)
                {
                    EnsureLoggedIn();
                    object data = new
                    {
                        @session     = SuiteCRMUserSession.id,
                        @module_name = moduleName
                    };

                    result = SuiteCRMUserSession.RestServer.GetCrmResponse <ModuleFields>("get_module_fields", data);
                    RestAPIWrapper.moduleFieldsCache[moduleName] = result;
                }
                else
                {
                    result = new ModuleFields();
                }
            }

            return(result);
        }
示例#2
0
        /// <summary>
        /// Get the module fields data for the module with this name, if any.
        /// </summary>
        /// <param name="module">the name of the module to query.</param>
        /// <returns>A structure of module's fields data.</returns>
        public static ModuleFields GetFieldsForModule(string module)
        {
            ModuleFields result;

            if (RestAPIWrapper.moduleFieldsCache.ContainsKey(module))
            {
                result = RestAPIWrapper.moduleFieldsCache[module];
            }
            else
            {
                if (!string.IsNullOrEmpty(module) && SuiteCRMUserSession != null)
                {
                    EnsureLoggedIn();
                    object data = new
                    {
                        @session     = SuiteCRMUserSession.id,
                        @module_name = module
                    };

                    result = SuiteCRMUserSession.RestServer.GetCrmResponse <ModuleFields>("get_module_fields", data);
                    RestAPIWrapper.moduleFieldsCache[module] = result;
                }
                else
                {
                    result = new ModuleFields();
                }
            }

            return(result);
        }
示例#3
0
    public static void FindModeBoolean(MonoBehaviour KMModule)
    {
        ModuleFields fields;

        if (!CachedFields.ContainsKey(KMModule))
        {
            fields = CachedFields[KMModule] = new ModuleFields();
            //Search all of the components in the module for Zen/Time fields
            var allComponents = KMModule.GetComponentsInChildren <Component>(true).Where(component => component != null);
            foreach (Component component in allComponents)
            {
                Type componentType = component.GetType();
                if (fields.ZenModeBool == null)
                {
                    fields.ZenModeBool = componentType.GetField("TwitchZenMode", modeFieldFlags) ?? componentType.GetField("ZenModeActive", modeFieldFlags);
                }
                if (fields.TimeModeBool == null)
                {
                    fields.TimeModeBool = componentType.GetField("TwitchTimeMode", modeFieldFlags) ?? componentType.GetField("TimeModeActive", modeFieldFlags);
                }

                if (fields.ZenModeBool != null && fields.TimeModeBool != null)
                {
                    break;
                }
            }
        }
        else
        {
            fields = CachedFields[KMModule];
        }

        if (fields.ZenModeBool != null && fields.ZenModeBool.FieldType == typeof(bool))
        {
            fields.ZenModeBool.SetValue(KMModule.GetComponentInChildren(fields.ZenModeBool.ReflectedType), Tweaks.CurrentMode == Mode.Zen);
        }

        if (fields.TimeModeBool != null && fields.TimeModeBool.FieldType == typeof(bool))
        {
            fields.TimeModeBool.SetValue(KMModule.GetComponentInChildren(fields.TimeModeBool.ReflectedType), Tweaks.CurrentMode == Mode.Time);
        }
    }