public override void ToJSON( JObject ParentObject ) { ParentObject[_SelectedViewIdsSubField.ToXmlNodeName()] = SelectedViewIds.ToString(); ParentObject["selectmode"] = SelectMode.ToString(); ParentObject[_CachedViewNameSubField.ToXmlNodeName()] = CachedViewNames.ToString(); ParentObject[ElemName_Options] = new JObject(); CswCheckBoxArrayOptions CBAOptions = new CswCheckBoxArrayOptions(); CBAOptions.Columns.Add( "Include" ); DataTable ViewsTable = ViewsForCBA(); foreach( DataRow ViewRow in ViewsTable.Rows ) { bool isSelected = SelectedViewIds.Contains( ViewRow[KeyColumn] ); if( IsEditModeEditable || isSelected ) { CswCheckBoxArrayOptions.Option Option = new CswCheckBoxArrayOptions.Option(); Option.Key = ViewRow[KeyColumn].ToString(); Option.Label = ViewRow[NameColumn].ToString(); Option.Values.Add( CswConvert.ToBoolean( ViewRow[ValueColumn] ) ); CBAOptions.Options.Add( Option ); } } CBAOptions.ToJSON( (JObject) ParentObject[ElemName_Options] ); } // ToJSON()
public override void ToJSON(JObject ParentObject) { ParentObject[_SelectedNodeTypeIdsSubField.ToXmlNodeName().ToLower()] = SelectedNodeTypeIds.ToString(); ParentObject["selectmode"] = SelectMode.ToString(); ParentObject[_ElemName_Options] = new JObject(); CswCheckBoxArrayOptions CBAOptions = new CswCheckBoxArrayOptions(); CBAOptions.Columns.Add("Include"); DataTable Data = Options; foreach (DataRow Row in Data.Rows) { bool isSelected = SelectedNodeTypeIds.Contains(Row[KeyColumn]); if (IsEditModeEditable || isSelected) { CswCheckBoxArrayOptions.Option Option = new CswCheckBoxArrayOptions.Option(); Option.Key = CswConvert.ToString(Row[KeyColumn]); Option.Label = CswConvert.ToString(Row[NameColumn]); Option.Values.Add(CswConvert.ToBoolean(Row[ValueColumn])); CBAOptions.Options.Add(Option); } } CBAOptions.ToJSON((JObject)ParentObject[_ElemName_Options]); } // ToJSON()
void BuyButtonsChange(bool buy) { t.text = "buy=" + buy.ToString() + " sm=" + SelectMode.ToString(); SetCost((Ships[CurrIndex].Price, Ships[CurrIndex].TokenPrice)); Buy.gameObject.SetActive(!buy); Select.gameObject.SetActive(buy && SelectMode); Selected.gameObject.SetActive(false); Upgrade.gameObject.SetActive(buy); }
public static void SetPrefs() { EditorPrefs.SetString(pb_Constant.pbDefaultSelectionMode, pbDefaultSelectionMode.ToString().ToLower()); EditorPrefs.SetString(pb_Constant.pbDefaultFaceColor, _faceColor.ToString()); EditorPrefs.SetBool(pb_Constant.pbDefaultOpenInDockableWindow, defaultOpenInDockableWindow); EditorPrefs.SetBool(pb_Constant.pbDefaultHideFaceMask, defaultHideFaceMask); EditorPrefs.SetString(pb_Constant.pbDefaultShortcuts, pb_Shortcut.ShortcutsToString(defaultShortcuts)); EditorPrefs.SetString(pb_Constant.pbDefaultMaterial, AssetDatabase.GetAssetPath(_defaultMaterial)); EditorPrefs.SetInt(pb_Constant.pbDefaultCollider, defaultColliderType); EditorPrefs.SetBool(pb_Constant.pbShowEditorNotifications, _showNotifications); EditorPrefs.SetBool(pb_Constant.pbForceConvex, pbForceConvex); EditorPrefs.SetBool(pb_Constant.pbDragCheckLimit, pbDragCheckLimit); EditorPrefs.SetBool(pb_Constant.pbForceVertexPivot, pbForceVertexPivot); EditorPrefs.SetBool(pb_Constant.pbForceGridPivot, pbForceGridPivot); EditorPrefs.SetBool(pb_Constant.pbPerimeterEdgeExtrusionOnly, pbPerimeterEdgeExtrusionOnly); EditorPrefs.SetBool(pb_Constant.pbPerimeterEdgeBridgeOnly, pbPerimeterEdgeBridgeOnly); // pb_Editor.instance.LoadPrefs(); }
internal bool ShouldFetchCollectionPersister() { if (!Joinable.IsCollection) { return(false); } switch (SelectMode) { case SelectMode.Undefined: return(JoinType == JoinType.LeftOuterJoin); case SelectMode.Fetch: case SelectMode.FetchLazyProperties: return(true); case SelectMode.ChildFetch: case SelectMode.JoinOnly: return(false); } throw new ArgumentOutOfRangeException(nameof(SelectMode), SelectMode.ToString()); }
/// <include file='doc\Socket.uex' path='docs/doc[@for="Socket.Poll"]/*' /> /// <devdoc> /// <para> /// Determines the status of the socket. /// </para> /// </devdoc> public bool Poll(int microSeconds, SelectMode mode) { if (CleanedUp) { throw new ObjectDisposedException(this.GetType().FullName); } FileDescriptorSet fileDescriptorSet = new FileDescriptorSet(1); fileDescriptorSet.Array[0] = m_Handle; TimeValue IOwait = new TimeValue(); // // negative timeout value implies indefinite wait // if (microSeconds>=0) { MicrosecondsToTimeValue(microSeconds, ref IOwait); } int errorCode; switch (mode) { case SelectMode.SelectRead: errorCode = (microSeconds>=0) ? UnsafeNclNativeMethods.OSSOCK.select( 0, ref fileDescriptorSet, IntPtr.Zero, IntPtr.Zero, ref IOwait) : UnsafeNclNativeMethods.OSSOCK.select( 0, ref fileDescriptorSet, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); break; case SelectMode.SelectWrite: errorCode = (microSeconds>=0) ? UnsafeNclNativeMethods.OSSOCK.select( 0, IntPtr.Zero, ref fileDescriptorSet, IntPtr.Zero, ref IOwait) : UnsafeNclNativeMethods.OSSOCK.select( 0, IntPtr.Zero, ref fileDescriptorSet, IntPtr.Zero, IntPtr.Zero); break; case SelectMode.SelectError: errorCode = (microSeconds>=0) ? UnsafeNclNativeMethods.OSSOCK.select( 0, IntPtr.Zero, IntPtr.Zero, ref fileDescriptorSet, ref IOwait) : UnsafeNclNativeMethods.OSSOCK.select( 0, IntPtr.Zero, IntPtr.Zero, ref fileDescriptorSet, IntPtr.Zero); break; default: throw new NotSupportedException(SR.GetString(SR.net_SelectModeNotSupportedException, mode.ToString())); }; // // if the native call fails we'll throw a SocketException // if (errorCode==SocketErrors.SocketError) { // // update our internal state after this socket error and throw // SocketException socketException = new SocketException(); UpdateStatusAfterSocketError(); throw socketException; } if (fileDescriptorSet.Count==0) { return false; } //return (fileDescriptorSet.Count!=0); return fileDescriptorSet.Array[0]==m_Handle; }
//will generate a type representing the passed-in type, and return the string //name of the type string Generate(Type type) { //root type is submitted var rootType = new TypeMetadata { Name = type.Name, Properties = new List <PropertyMetadata>() }; metadata.Types.Add(rootType); var props = type.GetRuntimeProperties(); foreach (var prop in props) { //skip these if (prop.PropertyType != typeof(LinkCollection) && !ignoreProperties.Contains(prop.Name)) { var propMetadata = new PropertyMetadata { Name = prop.Name, Type = GetTypeDescriptor(prop.PropertyType), DisplayInfo = new DisplayInfo { Required = prop.IsDefined(typeof(RequiredAttribute)), Description = prop.GetCustomAttribute <DescriptionAttribute>()?.Description, ShowCopyToClipboard = prop.IsDefined(typeof(AllowCopyToClipboardAttribute)) } }; //accepts [DisplayName()] or [Display(Name=)] -> defaults to property name if (prop.IsDefined(typeof(DisplayNameAttribute))) { propMetadata.DisplayInfo.Label = prop.GetCustomAttribute <DisplayNameAttribute>()?.DisplayName ?? string.Empty; } else if (prop.IsDefined(typeof(DisplayAttribute))) { propMetadata.DisplayInfo.Label = prop.GetCustomAttribute <DisplayAttribute>()?.Name ?? string.Empty; } else { propMetadata.DisplayInfo.Label = prop.Name; } //accepts [ReadOnly()] or [Writeable] -> defaults to true (Read Only) if (prop.IsDefined(typeof(ReadOnlyAttribute))) { propMetadata.DisplayInfo.ReadOnly = prop.GetCustomAttribute <ReadOnlyAttribute>()?.IsReadOnly == true; } else if (prop.IsDefined(typeof(WriteableAttribute))) { propMetadata.DisplayInfo.ReadOnly = false; } else { propMetadata.DisplayInfo.ReadOnly = true; } //selectable metadata is not currently supported in the UI if (prop.IsDefined(typeof(SelectableAttribute))) { if (prop.IsDefined(typeof(HasOptionsAttribute))) { var optionsAttr = prop.GetCustomAttribute <HasOptionsAttribute>(); propMetadata.DisplayInfo.Options = new OptionsMetadata { SelectMode = optionsAttr?.SelectMode.ToString() }; if (prop.PropertyType.GetTypeInfo().IsEnum) { var enumType = prop.PropertyType; propMetadata.DisplayInfo.Options.Values = ProjectEnum(enumType); } } else if (prop.IsDefined(typeof(ListApiAttribute))) { var listApiAttr = prop.GetCustomAttribute <ListApiAttribute>(); propMetadata.DisplayInfo.ListApi = new ListApiMetadata(listApiAttr !.SelectMode.ToString(), listApiAttr !.ApiEndpoint); } } if (prop.IsDefined(typeof(PropertyApplicabilityAttribute))) { var applicableAttr = prop.GetCustomAttribute <PropertyApplicabilityAttribute>(); propMetadata.DisplayInfo.PropertyApplicability = new PropertyApplicability(applicableAttr !.Mode, applicableAttr.DependsOnPropertyName) { DependsOnPropertyValue = applicableAttr.DependsOnPropertyValue }; } if (prop.IsDefined(typeof(AllowConnectivityCheckAttribute))) { var allowConnectivityCheckAttr = prop.GetCustomAttribute <AllowConnectivityCheckAttribute>(); propMetadata.DisplayInfo.ConnectivityCheck = new ConnectivityCheck { Title = allowConnectivityCheckAttr !.ConnectivityCheckTitle, Url = allowConnectivityCheckAttr.ApiEndpoint, DependsOnPropertyNames = allowConnectivityCheckAttr.DependsOnPropertyNames }; } rootType.Properties.Add(propMetadata); } } return(rootType.Name); } Dictionary <string, string> ProjectEnum(Type enumType) { if (!enumType.GetTypeInfo().IsEnum) { throw new Exception("Parameter must be an enum"); } var values = new Dictionary <string, string>(); foreach (var item in Enum.GetValues(enumType)) { values.Add(item.ToString() !, EnumExtensions.GetDescription(enumType, item)); } return(values); } string GetTypeDescriptor(Type type) { //Array if (type.IsArray) { return(GetTypeDescriptor(type.GetElementType() !) + "[]"); } if (type.GetTypeInfo().IsGenericType) { var genericTypeDefinition = type.GetGenericTypeDefinition(); //List<> if (genericTypeDefinition.GetTypeInfo().IsAssignableFrom(typeof(List <>).GetTypeInfo())) { var genericType = type.GetTypeInfo().GenericTypeArguments[0]; return(GetTypeDescriptor(genericType) + "[]"); } //Dictionary<> if (genericTypeDefinition.GetTypeInfo().IsAssignableFrom(typeof(Dictionary <,>).GetTypeInfo())) { var genericTypes = type.GetTypeInfo().GenericTypeArguments; var keyType = GetTypeDescriptor(genericTypes[0]); var valueType = GetTypeDescriptor(genericTypes[1]); return($"Dictionary<{keyType}, {valueType}>"); } //other generics not supported yet } //Nullable var underlyingType = Nullable.GetUnderlyingType(type); if (underlyingType != null) { return(GetTypeDescriptor(underlyingType) + "?"); } //Enum if (type.GetTypeInfo().IsEnum) { //for enums, we will map the values into the property itself and assume a // string on the wire return("string"); } //approved primitive / value-type mappings if (mappings.TryGetValue(type, out var descriptor)) { return(descriptor); } //if we drop down here, first check if the type is already mapped: //if not, map the type into the types collection and just //return the type name to link them together if (metadata.Types.All(t => t.Name != type.Name)) { return(Generate(type)); } //otherwise we just return the already mapped name :) return(type.Name); } } }
/// <summary> /// Selects values/text/indices from the specified field selector. /// </summary> /// <param name="fieldSelector">The field selector.</param> /// <param name="conditions">The conditions.</param> public void From(string fieldSelector, MatchConditions conditions) { if (CommandManager.EnableRemoteExecution) { // args var arguments = new Dictionary <string, dynamic>(); arguments.Add("selector", fieldSelector); arguments.Add("selectMode", _selectMode.ToString()); arguments.Add("matchConditions", conditions.ToString()); if (_values != null) { arguments.Add("values", _values); } if (_optionMatchingFunc != null) { arguments.Add("valueExpression", _optionMatchingFunc.ToExpressionString()); } if (_selectedIndices != null) { arguments.Add("indices", _selectedIndices); } CommandManager.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails() { Name = "Select", Arguments = arguments }); } else { CommandManager.CurrentActionBucket.Add(() => { var field = Provider.GetSelectElement(fieldSelector, conditions); field.ClearSelectedItems(); if (_selectMode == SelectMode.Value || _selectMode == SelectMode.Text) { if (_optionMatchingFunc == null) { if (_values.Length == 1) { field.SetValue(_values.First(), _selectMode); } else if (_values.Length > 1) { field.SetValues(_values, _selectMode); } } else { field.SetValues(_optionMatchingFunc, _selectMode); } } else if (_selectMode == SelectMode.Index) { if (_selectedIndices.Length == 1) { field.SetSelectedIndex(_selectedIndices.First()); } else if (_selectedIndices.Length > 1) { field.SetSelectedIndices(_selectedIndices); } } }); } }