public void Launch (GLib.File app, IEnumerable<GLib.File> files) { if (app != null && !app.Exists) { Log<SystemService>.Warn ("Application {0} doesnt exist", app.Path); return; } List<GLib.File> noMountNeeded = new List<GLib.File> (); // before we try to use the files, make sure they are mounted foreach (GLib.File f in files) { // if the path isn't empty, // check if it's a local file or on VolumeMonitor's mount list. // if it is, skip it. if (!string.IsNullOrEmpty (f.Path) && (f.IsNative || VolumeMonitor.Default.Mounts.Any (m => f.Path.Contains (m.Root.Path)))) { noMountNeeded.Add (f); continue; } // if the file has no path, there are 2 possibilities // either it's a "fake" file, like computer:// or trash:// // or it's a mountable file that isn't mounted // this launches the "fake" files": try { GLib.AppInfoAdapter.LaunchDefaultForUri (f.StringUri (), null); // FIXME: until we use a more recent Gtk# (one that exposes the GException code // we'll just have to silently fail and assume it's an unmounted but mountable file } catch { // otherwise: // try to mount, if successful launch, otherwise (it's possibly already mounted) try to launch anyways f.MountWithActionAndFallback (() => LaunchWithFiles (app, new [] {f}), () => LaunchWithFiles (app, new [] {f})); } } if (noMountNeeded.Any () || !files.Any ()) LaunchWithFiles (app, noMountNeeded); }
static bool RequireGenerics (IMethodSymbol method) { System.Collections.Immutable.ImmutableArray<ITypeSymbol> typeArgs; if (method.MethodKind == MethodKind.Constructor) { typeArgs = method.ContainingType.TypeArguments; } else { typeArgs = method.TypeArguments; } if (!typeArgs.Any (ta => ta.TypeKind == TypeKind.TypeParameter)) return false; var parameterTypes = new List<ITypeSymbol> (method.Parameters.Select (p => p.Type)); if (method.IsExtensionMethod) { parameterTypes.Add (method.ReducedFrom.Parameters [0].Type); } return typeArgs.Any (t => !parameterTypes.Any (pt => ContainsType (pt, t))); }
public void SetElementVariables() { var state = AppController.Instance.CurrentState as PropertiesState; if (state == null || state.Element == null) { return; } var vars = new List<Variable> (); string variable; VariableType t; var c = state.Element.GetVariablesCount (); if (c > 0) { GetPropertyData (cbDefaultVar, cbExistVar, etNewVar, rbDefault, rbExisting, rbNew, out variable, out t); if (variable != null) { vars.Add (new Variable{ Value = variable, Type = t }); } } if (c > 1) { GetPropertyData (cbDefaultVar1, cbExistVar1, etNewVar1, rbDefault1, rbExisting1, rbNew1, out variable, out t); if (variable != null) { vars.Add (new Variable{ Value = variable, Type = t }); } } if (c > 2) { GetPropertyData (cbDefaultVar2, cbExistVar2, etNewVar2, rbDefault2, rbExisting2, rbNew2, out variable, out t); if (variable != null) { vars.Add (new Variable{ Value = variable, Type = t }); } } if (c > 3) { GetPropertyData (cbDefaultVar3, cbExistVar3, etNewVar3, rbDefault3, rbExisting3, rbNew3, out variable, out t); if (variable != null) { vars.Add (new Variable{ Value = variable, Type = t }); } } if (vars.Any()) { AppController.Instance.SetElementVariable (vars); } }