本文整理汇总了C#中ScriptCoreLib.FirstOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptCoreLib.FirstOrDefault方法的具体用法?C# ScriptCoreLib.FirstOrDefault怎么用?C# ScriptCoreLib.FirstOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScriptCoreLib
的用法示例。
在下文中一共展示了ScriptCoreLib.FirstOrDefault方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Application
//.........这里部分代码省略.........
{
int __device_id = int.Parse(xml.Attribute("device_id").Value);
if (__device_id == device_id)
{
// are we being reconfigured?
friendly_devices.Where(k => k.source_device_id == source_device_id).WithEach(
q =>
{
int dx = int.Parse(xml.Attribute("dx").Value);
int dy = int.Parse(xml.Attribute("dy").Value);
disable_bind_reconfigure = true;
q.f.MoveTo(
fw.Left - dx,
fw.Top - dy
);
disable_bind_reconfigure = false;
}
);
}
}
#endregion
#region at_virtualwindowsync
if (source_device_id != 0)
if (xml.Name.LocalName == "at_virtualwindowsync")
{
Console.WriteLine("got at_virtualwindowsync");
// do we know this device?
var q = friendly_devices.FirstOrDefault(k => k.source_device_id == source_device_id);
int w = int.Parse(xml.Attribute("w").Value);
int h = int.Parse(xml.Attribute("h").Value);
Action reposition = delegate { };
if (q == null)
{
var fc = new Form { Text = new { source_device_id }.ToString() };
q = new { source_device_id, f = fc, children = new { child_id = 0, fc = default(Form) }.ToEmptyList() };
friendly_devices.Add(q);
q.f.StartPosition = FormStartPosition.Manual;
q.f.Show();
// show should respect opacity?
q.f.Opacity = 0.3;
// where to put it?
// left or right?
var max_right = fvs.OwnedForms.Max(k => k.Right);
var min_left = fvs.OwnedForms.Min(k => k.Left);
if (source_device_id < device_id)
q.f.Left = min_left - w;
else
q.f.Left = max_right;
q.f.Top = fw.Top;
示例2: Handler
public /* will not be part of web service itself */ void Handler(WebServiceHandler h)
{
if (h.Context.Request.Path == "/jsc")
{
h.Diagnostics();
return;
}
var HostUri = new
{
Host = h.Context.Request.Headers["Host"].TakeUntilIfAny(":"),
Port = h.Context.Request.Headers["Host"].SkipUntilIfAny(":")
};
var apps = new[]
{
new { path = "/WebGLLesson10", client = h.Applications.FirstOrDefault(k => k.TypeName == "__WebGLLesson10Application") },
new { path = "/WebGLSpiral", client = h.Applications.FirstOrDefault(k => k.TypeName == "__WebGLSpiral") },
new { path = "/ImpAdventures", client = h.Applications.FirstOrDefault(k => k.TypeName == "__ImpAdventures") },
new { path = "/IsometricTycoonViewWithToolbar", client = h.Applications.FirstOrDefault(k => k.TypeName == "__IsometricTycoonViewWithToolbar") },
new { path = "/McKrackenFirstRoom", client = h.Applications.FirstOrDefault(k => k.TypeName == "__McKrackenFirstRoom") },
//new { path = "/AvalonUgh", client = h.Applications.FirstOrDefault(k => k.TypeName == "__AvalonUgh") },
//new { path = "/JavaDosBoxQuakeBeta", client = h.Applications.FirstOrDefault(k => k.TypeName == "__JavaDosBoxQuakeBeta") },
//new { path = "/Boing4KTemplate", client = h.Applications.FirstOrDefault(k => k.TypeName == "__Boing4KTemplate") },
//new { path = "/RayCasterApplet", client = h.Applications.FirstOrDefault(k => k.TypeName == "__RayCasterApplet") },
//new { path = "/FlashCamera", client = h.Applications.FirstOrDefault(k => k.TypeName == "__FlashCamera") },
new { path = "", client = h.Applications.FirstOrDefault(k => k.TypeName =="Application") }
};
#region app
var app = apps.FirstOrDefault(
k =>
{
if (k.path == h.Context.Request.Path)
return true;
if (h.Context.Request.Path == k.path + "/view-source")
return true;
if (h.Context.Request.Path.StartsWith(k.path))
return true;
// default
if (k.path == "")
return true;
return false;
}
);
#endregion
#region /view-source
if (h.Context.Request.Path == app.path + "/view-source")
{
h.Context.Response.ContentType = "text/javascript";
//// Accept-Encoding: gzip,deflate,sdch
//foreach (var item in app.client.References)
//{
// h.Context.Response.Write("/* " + new { item.AssemblyFile, bytes = 1 } + " */\r\n");
//}
//foreach (var item in app.client.References)
//{
// // asp.net needs absolute paths
// //h.Context.Response.WriteFile("/" + item.AssemblyFile + ".js");
// // what if it does not exist?
// h.Context.Response.WriteFile(item.AssemblyFile + ".js");
//}
h.WriteSource(app.client);
h.CompleteRequest();
return;
}
#endregion
if (app.client != null)
{
h.Context.Response.ContentType = "text/html";
var xml = XElement.Parse(app.client.PageSource);
xml.Add(
new XElement("script",
new XAttribute("src", app.path + "/view-source"),
// android otherwise closes the tag?
" "
)
);
h.Context.Response.Write(xml.ToString());
//.........这里部分代码省略.........
示例3: Handler
//.........这里部分代码省略.........
<d:DownloadCount m:type=""Edm.Int32"">200</d:DownloadCount>
<d:RequireLicenseAcceptance m:type=""Edm.Boolean"">false</d:RequireLicenseAcceptance>
<d:Description>$59.99
jsc-solutions.net</d:Description>
<d:ReleaseNotes m:null=""true"">notes</d:ReleaseNotes>
<d:Published m:type=""Edm.DateTime"">2012-10-21T10:55:45.4825886Z</d:Published>
<d:Dependencies></d:Dependencies>
<d:PackageHash>H0LvR29MtBUeY8bPDkTW6lHhQfixAGjxScIIC97XUJyu7wPmrdQQmbV3cgAelyBEWpn38kTtg8xVMe0ujhChGg==</d:PackageHash>
<d:PackageHashAlgorithm>SHA512</d:PackageHashAlgorithm>
<d:PackageSize m:type=""Edm.Int64"">4495</d:PackageSize>
<d:Copyright m:null=""true""></d:Copyright>
<d:Tags m:null=""true""></d:Tags>
<d:IsAbsoluteLatestVersion m:type=""Edm.Boolean"">true</d:IsAbsoluteLatestVersion>
<d:IsLatestVersion m:type=""Edm.Boolean"">true</d:IsLatestVersion>
<d:Listed m:type=""Edm.Boolean"">false</d:Listed>
<d:VersionDownloadCount m:type=""Edm.Int32"">100</d:VersionDownloadCount>
<d:Summary m:null=""true""></d:Summary>
</m:properties>
</entry>
").Replace("localhost:59019", HostUri.Host + ":" + HostUri.Port);
Console.WriteLine(u);
h.Context.Response.Write(
u
);
}
);
h.Context.Response.Write(
@"
</feed>
".Replace("localhost:59019", HostUri.Host + ":" + HostUri.Port)
);
h.CompleteRequest();
return;
}
#endregion
#region TestNuGetSupport.Foo.0.0.0.1.nupkg
var x = "/api/v2/package/testnugetsupport.foo/0.0.0.1";
// anonymous extensions?
var xx = nugetoutput.FirstOrDefault(k => h.Context.Request.Path == "/io/" + k.TargetName + "." + k.Version);
if (xx != null)
{
#region AuthorizationLiteralCredentials
if (string.IsNullOrEmpty(AuthorizationLiteralCredentials.user))
{
if (string.IsNullOrEmpty(AuthorizationLiteralCredentials.user))
{
WWWAuthenticate();
return;
}
return;
}
#endregion
var f = "assets/TestNuGetSupport.FeedServer/" + xx.TargetName + "." + xx.Version + ".nupkg";
// Could not find a part of the path 'V:\staging.net.debug\api\v2\package\testnugetsupport.foo\assets\TestNuGetSupport.FeedServer\TestNuGetSupport.Foo.0.0.0.1.nupkg'.
// WebDev is relativet to request.
h.Context.Response.WriteFile("/" + f);
h.CompleteRequest();
return;
}
#endregion
if (h.IsDefaultPath)
{
if (h.Context.Request.Headers["User-Agent"].StartsWith("NuGet/"))
{
// redirect that guy!
h.Context.Response.Redirect("/nuget");
h.CompleteRequest();
}
return;
}
if (h.Context.Request.Path == "/jsc")
return;
h.Context.Response.StatusCode = 500;
h.CompleteRequest();
}